mr-manager is a wait-free, per-type memory pool object manager for C++23, designed for high-performance, concurrent applications. It leverages folly for synchronization and concurrent hash maps, and uses C++ polymorphic memory resources for efficient memory management.
- Wait-free object management
- Per-type memory pools using C++17 polymorphic allocators
- Concurrent access via folly's
ConcurrentHashMap - Type-safe handles for asset access
- C++23 compatible compiler
- Conan for dependency management
- CMake >= 3.26 (handled by Conan)
- folly (handled by Conan)
- fmt (handled by Conan)
- (Linux, optional) mold linker (handled by Conan)
conan install . --build=missingconan build .Below is a minimal example of how to use mr-manager to manage a custom type:
#include <mr-manager/manager.hpp>
#include <iostream>
#include <string>
struct MyAsset {
std::string str;
int num;
MyAsset(std::string n, int v) : name(std::move(n)), value(v) {}
};
int main() {
// Get the singleton manager for MyAsset
auto& manager = mr::Manager<MyAsset>::get();
// Create an asset (the hash of arguments is used as the ID)
auto handle = manager.create("custom asset id", "forty two", 42);
// Access the asset using the handle
std::println("String: {}; Number: {}", handle->str, handle->num);
}mr::Manager<T>::get()returns a singleton manager for typeT.manager.create(id, args...)constructs a new asset of typeTwith the given arguments, or returns a handle to an existing one with the same id.Handle<T>::operator->safely accesses the asset
To use mr-manager in your own project:
-
Add it as a Conan dependency in your
conanfile.txtorconanfile.py:[requires] mr-manager/1.0 -
Link against the library in your CMake project:
find_package(mr-manager REQUIRED) target_link_libraries(your_target PRIVATE mr-manager::mr-manager)
MIT