ObjMatrix  Check-in [5d9f93730c]

Overview
Comment:MTXStorage: Add transactions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5d9f93730cae9ba8132f233ccab7d0aa1a47d26a6e56085558bd2b8a2b483ca5
User & Date: js on 2020-10-04 01:33:43
Other Links: manifest | tags
Context
2020-10-06
20:48
Initial skeleton for handling sync check-in: 4df5567c11 user: js tags: trunk
2020-10-04
01:33
MTXStorage: Add transactions check-in: 5d9f93730c user: js tags: trunk
01:18
Include "since" in sync check-in: 2682b2dc32 user: js tags: trunk
Changes

Modified src/MTXSQLite3Storage.m from [1f1db09c0f] to [8d08466130].

77
78
79
80
81
82
83





84
85
86
87
88
89
90
- (void)createTables
{
	[_conn executeStatement: @"CREATE TABLE IF NOT EXISTS next_batch (\n"
				 @"    device_id TEXT PRIMARY KEY,\n"
				 @"    next_batch TEXT\n"
				 @")"];
}






- (void)setNextBatch: (OFString *)nextBatch
	 forDeviceID: (OFString *)deviceID
{
	void *pool = objc_autoreleasePoolPush();

	[_nextBatchSetStatement reset];







>
>
>
>
>







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
- (void)createTables
{
	[_conn executeStatement: @"CREATE TABLE IF NOT EXISTS next_batch (\n"
				 @"    device_id TEXT PRIMARY KEY,\n"
				 @"    next_batch TEXT\n"
				 @")"];
}

- (void)transactionWithBlock: (mtx_storage_transaction_block_t)block
{
	[_conn transactionWithBlock: block];
}

- (void)setNextBatch: (OFString *)nextBatch
	 forDeviceID: (OFString *)deviceID
{
	void *pool = objc_autoreleasePoolPush();

	[_nextBatchSetStatement reset];

Modified src/MTXStorage.h from [9ebb54087f] to [8e365a3b3e].

20
21
22
23
24
25
26








27
28
29
30





31
32
33
34
35
36
37
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN









/**
 * @brief A protocol for a storage to be used by @ref MTXClient.
 */
@protocol MTXStorage <OFObject>





/**
 * @brief Stores the next batch for the specified device.
 *
 * @param nextBatch The next batch for the device
 * @param deviceID The device for which to store the next batch
 */
- (void)setNextBatch: (OFString *)nextBatch







>
>
>
>
>
>
>
>




>
>
>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

/**
 * @brief A block which will be treated as a single transaction for the storage.
 *
 * @return Whether the transaction should be committed (`true`) or rolled back
 *	   (`false`).
 */
typedef bool (^mtx_storage_transaction_block_t)(void);

/**
 * @brief A protocol for a storage to be used by @ref MTXClient.
 */
@protocol MTXStorage <OFObject>
/**
 * @brief Performs all operations inside the block as a transaction.
 */
- (void)transactionWithBlock: (mtx_storage_transaction_block_t)block;

/**
 * @brief Stores the next batch for the specified device.
 *
 * @param nextBatch The next batch for the device
 * @param deviceID The device for which to store the next batch
 */
- (void)setNextBatch: (OFString *)nextBatch