Files
versioned-map/RootSet.h

48 lines
1.1 KiB
C++

#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`, and they only read versions >= `oldestVersion` and <= the
/// version as of obtaining the handle.
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;
};