Document thread-safety in terms of constness
This commit is contained in:
@@ -2639,6 +2639,12 @@ ConflictSet_getBytes(void *cs) {
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure abi is well-defined
|
||||
static_assert(std::is_standard_layout_v<ConflictSet::Result>);
|
||||
static_assert(std::is_standard_layout_v<ConflictSet::Key>);
|
||||
static_assert(std::is_standard_layout_v<ConflictSet::ReadRange>);
|
||||
static_assert(std::is_standard_layout_v<ConflictSet::WriteRange>);
|
||||
|
||||
namespace {
|
||||
|
||||
std::string getSearchPathPrintable(Node *n) {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user