Improve ConflictSet.h readability
All checks were successful
Tests / Release [gcc] total: 704, passed: 704
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/67//gcc">weaselab » conflict-set » main #67</a>
Tests / Release [gcc,aarch64] total: 703, passed: 703
Tests / Coverage total: 702, passed: 702
weaselab/conflict-set/pipeline/head This commit looks good
All checks were successful
Tests / Release [gcc] total: 704, passed: 704
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Reference build: <a href="https://jenkins.weaselab.dev/job/weaselab/job/conflict-set/job/main/67//gcc">weaselab » conflict-set » main #67</a>
Tests / Release [gcc,aarch64] total: 703, passed: 703
Tests / Coverage total: 702, passed: 702
weaselab/conflict-set/pipeline/head This commit looks good
This commit is contained in:
@@ -31,12 +31,15 @@ struct __attribute__((__visibility__("default"))) ConflictSet {
|
|||||||
`setOldestVersion` */
|
`setOldestVersion` */
|
||||||
TooOld
|
TooOld
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Bytes ordered lexicographically */
|
/** Bytes ordered lexicographically */
|
||||||
struct Key {
|
struct Key {
|
||||||
const uint8_t *p;
|
const uint8_t *p;
|
||||||
int len;
|
int len;
|
||||||
};
|
};
|
||||||
/** Denotes a set of keys to be checked for conflicts */
|
|
||||||
|
/** Denotes a set of keys to be checked for conflicting writes since
|
||||||
|
* `readVersion` */
|
||||||
struct ReadRange {
|
struct ReadRange {
|
||||||
Key begin;
|
Key begin;
|
||||||
/** `end` having length 0 denotes that this range is the single key {begin}.
|
/** `end` having length 0 denotes that this range is the single key {begin}.
|
||||||
@@ -44,6 +47,7 @@ struct __attribute__((__visibility__("default"))) ConflictSet {
|
|||||||
Key end;
|
Key end;
|
||||||
int64_t readVersion;
|
int64_t readVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Denotes a set of keys to be written at `writeVersion` */
|
/** Denotes a set of keys to be written at `writeVersion` */
|
||||||
struct WriteRange {
|
struct WriteRange {
|
||||||
Key begin;
|
Key begin;
|
||||||
@@ -51,21 +55,25 @@ struct __attribute__((__visibility__("default"))) ConflictSet {
|
|||||||
* Otherwise this denotes the range [begin, end) */
|
* Otherwise this denotes the range [begin, end) */
|
||||||
Key end;
|
Key end;
|
||||||
};
|
};
|
||||||
/** The result of checking reads[i] is written in results[i]. */
|
|
||||||
|
/** The result of checking reads[i] is written in results[i] */
|
||||||
void check(const ReadRange *reads, Result *results, int count) const;
|
void check(const ReadRange *reads, Result *results, int count) const;
|
||||||
|
|
||||||
/** `writes` must be sorted ascending, and must not have adjacent or
|
/** `writes` must be sorted ascending, and must not have adjacent or
|
||||||
* overlapping ranges. Reads intersecting writes where readVersion <
|
* overlapping ranges. Reads intersecting writes where readVersion <
|
||||||
* `writeVersion` will result in `Conflict` (or `TooOld`, eventually).
|
* `writeVersion` will result in `Conflict` (or `TooOld`, eventually).
|
||||||
* `writeVersion must be greater than all write versions in all previous
|
* `writeVersion` must be greater than every write version in all previous
|
||||||
* calls to `addWrites` */
|
* calls to `addWrites` */
|
||||||
void addWrites(const WriteRange *writes, int count, int64_t writeVersion);
|
void addWrites(const WriteRange *writes, int count, int64_t writeVersion);
|
||||||
|
|
||||||
/** Reads where readVersion < oldestVersion will result in `TooOld`. Must be
|
/** Reads where readVersion < oldestVersion will result in `TooOld`. Must be
|
||||||
* greater than any previous oldestVersion. */
|
* greater than any previous oldestVersion */
|
||||||
void setOldestVersion(int64_t oldestVersion);
|
void setOldestVersion(int64_t oldestVersion);
|
||||||
|
|
||||||
/** Reads where readVersion < oldestVersion will result in `TooOld`. There are
|
/** Reads where readVersion < oldestVersion will result in `TooOld`. There are
|
||||||
* no writes initially. */
|
* no writes initially */
|
||||||
explicit ConflictSet(int64_t oldestVersion);
|
explicit ConflictSet(int64_t oldestVersion);
|
||||||
|
|
||||||
~ConflictSet();
|
~ConflictSet();
|
||||||
|
|
||||||
#if __cplusplus > 199711L
|
#if __cplusplus > 199711L
|
||||||
@@ -96,12 +104,15 @@ typedef enum {
|
|||||||
`setOldestVersion` */
|
`setOldestVersion` */
|
||||||
ConflictSet_TooOld
|
ConflictSet_TooOld
|
||||||
} ConflictSet_Result;
|
} ConflictSet_Result;
|
||||||
|
|
||||||
/** Bytes ordered lexicographically */
|
/** Bytes ordered lexicographically */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const uint8_t *p;
|
const uint8_t *p;
|
||||||
int len;
|
int len;
|
||||||
} ConflictSet_Key;
|
} ConflictSet_Key;
|
||||||
/** Denotes a set of keys to be checked for conflicts */
|
|
||||||
|
/** Denotes a set of keys to be checked for conflicting writes since
|
||||||
|
* `readVersion` */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ConflictSet_Key begin;
|
ConflictSet_Key begin;
|
||||||
/** `end` having length 0 denotes that this range is the single key {begin}.
|
/** `end` having length 0 denotes that this range is the single key {begin}.
|
||||||
@@ -109,6 +120,7 @@ typedef struct {
|
|||||||
ConflictSet_Key end;
|
ConflictSet_Key end;
|
||||||
int64_t readVersion;
|
int64_t readVersion;
|
||||||
} ConflictSet_ReadRange;
|
} ConflictSet_ReadRange;
|
||||||
|
|
||||||
/** Denotes a set of keys to be written at `writeVersion` */
|
/** Denotes a set of keys to be written at `writeVersion` */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ConflictSet_Key begin;
|
ConflictSet_Key begin;
|
||||||
@@ -117,23 +129,27 @@ typedef struct {
|
|||||||
ConflictSet_Key end;
|
ConflictSet_Key end;
|
||||||
} ConflictSet_WriteRange;
|
} ConflictSet_WriteRange;
|
||||||
|
|
||||||
/** The result of checking reads[i] is written in results[i]. */
|
/** The result of checking reads[i] is written in results[i] */
|
||||||
void ConflictSet_check(ConflictSet *cs, const ConflictSet_ReadRange *reads,
|
void ConflictSet_check(ConflictSet *cs, const ConflictSet_ReadRange *reads,
|
||||||
ConflictSet_Result *results, int count);
|
ConflictSet_Result *results, int count);
|
||||||
|
|
||||||
/** `writes` must be sorted ascending, and must not have adjacent or
|
/** `writes` must be sorted ascending, and must not have adjacent or
|
||||||
* overlapping ranges. Reads intersecting writes where readVersion <
|
* overlapping ranges. Reads intersecting writes where readVersion <
|
||||||
* `writeVersion` will result in `Conflict` (or `TooOld`, eventually).
|
* `writeVersion` will result in `Conflict` (or `TooOld`, eventually).
|
||||||
* `writeVersion must be greater than all write versions in all previous
|
* `writeVersion` must be greater than all write versions in all previous
|
||||||
* calls to `addWrites` */
|
* calls to `addWrites` */
|
||||||
void ConflictSet_addWrites(ConflictSet *cs,
|
void ConflictSet_addWrites(ConflictSet *cs,
|
||||||
const ConflictSet_WriteRange *writes, int count,
|
const ConflictSet_WriteRange *writes, int count,
|
||||||
int64_t writeVersion);
|
int64_t writeVersion);
|
||||||
|
|
||||||
/** Reads where readVersion < oldestVersion will result in `TooOld`. Must be
|
/** Reads where readVersion < oldestVersion will result in `TooOld`. Must be
|
||||||
* greater than any previous oldestVersion. */
|
* greater than any previous oldestVersion */
|
||||||
void ConflictSet_setOldestVersion(ConflictSet *cs, int64_t oldestVersion);
|
void ConflictSet_setOldestVersion(ConflictSet *cs, int64_t oldestVersion);
|
||||||
|
|
||||||
/** Reads where readVersion < oldestVersion will result in `TooOld`. There are
|
/** Reads where readVersion < oldestVersion will result in `TooOld`. There are
|
||||||
* no writes initially. */
|
* no writes initially */
|
||||||
ConflictSet *ConflictSet_create(int64_t oldestVersion);
|
ConflictSet *ConflictSet_create(int64_t oldestVersion);
|
||||||
|
|
||||||
void ConflictSet_destroy(ConflictSet *cs);
|
void ConflictSet_destroy(ConflictSet *cs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user