Prepare for firstGeq to be safe on foreign threads
This commit is contained in:
46
RootSet.h
Normal file
46
RootSet.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <stdint.h>
|
||||
|
||||
struct RootSet {
|
||||
|
||||
/// Register the root node for version after adding mutations
|
||||
void add(uint32_t node, int64_t version);
|
||||
|
||||
/// Inform that there will be no calls to rootForVersion with a version less
|
||||
/// than `oldestVersion`
|
||||
void setOldestVersion(int64_t oldestVersion);
|
||||
|
||||
/// Foreign threads may freely interact with a `ThreadSafeHandle`, as long as
|
||||
/// the latest version as of obtaining the handle is greater than
|
||||
/// `oldestVersion`.
|
||||
struct ThreadSafeHandle {
|
||||
|
||||
/// Get a root node that can correctly be used for `version`
|
||||
uint32_t rootForVersion(int64_t version) const;
|
||||
|
||||
/// @private
|
||||
struct Impl;
|
||||
|
||||
private:
|
||||
Impl *impl; // not owned
|
||||
};
|
||||
|
||||
/// Safe to call from foreign threads
|
||||
ThreadSafeHandle getThreadSafeHandle() const;
|
||||
|
||||
const uint32_t *roots() const;
|
||||
int rootCount() const;
|
||||
|
||||
RootSet();
|
||||
|
||||
~RootSet();
|
||||
|
||||
/// @private
|
||||
struct Impl;
|
||||
|
||||
private:
|
||||
Impl *impl;
|
||||
};
|
Reference in New Issue
Block a user