Document thread-safety in terms of constness

This commit is contained in:
2024-03-20 16:16:15 -07:00
parent cda28643a6
commit b7cdecaf71
2 changed files with 12 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ limitations under the License.
* - It's safe to operate on two different ConflictSets in two different
* threads concurrently
* - It's safe to have multiple threads operating on the same ConflictSet
* concurrently if and only if all threads only call `check`.
* concurrently if and only if all threads only call const methods
*/
struct __attribute__((__visibility__("default"))) ConflictSet {
enum Result {
@@ -110,7 +110,8 @@ private:
* - It's safe to operate on two different ConflictSets in two different
* threads concurrently
* - It's safe to have multiple threads operating on the same ConflictSet
* concurrently if and only if all threads only call `check`.
* concurrently if and only if all threads only call functions that accept a
* const ConflictSet pointer
*/
typedef struct ConflictSet ConflictSet;
@@ -150,7 +151,8 @@ typedef struct {
} ConflictSet_WriteRange;
/** The result of checking reads[i] is written in results[i] */
void ConflictSet_check(ConflictSet *cs, const ConflictSet_ReadRange *reads,
void ConflictSet_check(const ConflictSet *cs,
const ConflictSet_ReadRange *reads,
ConflictSet_Result *results, int count);
/** `writes` must be sorted ascending, and must not have adjacent or
@@ -173,6 +175,6 @@ ConflictSet *ConflictSet_create(int64_t oldestVersion);
void ConflictSet_destroy(ConflictSet *cs);
/** Returns the total bytes in use by this ConflictSet */
int64_t ConflictSet_getBytes(ConflictSet *cs);
int64_t ConflictSet_getBytes(const ConflictSet *cs);
#endif