18 #ifndef FOEDUS_MEMORY_SHARED_MEMORY_HPP_
19 #define FOEDUS_MEMORY_SHARED_MEMORY_HPP_
22 #include <sys/types.h>
96 : size_(0), numa_node_(0), shmid_(0), shmkey_(0), owner_pid_(0), block_(
CXX11_NULLPTR) {}
102 #ifndef DISABLE_CXX11_IN_PUBLIC_HEADERS
111 #endif // DISABLE_CXX11_IN_PUBLIC_HEADERS
129 ErrorStack alloc(
const std::string& meta_path, uint64_t size,
int numa_node,
bool use_hugepages);
139 void attach(
const std::string& meta_path,
bool use_hugepages);
181 std::string meta_path_;
202 #endif // FOEDUS_MEMORY_SHARED_MEMORY_HPP_
~SharedMemory()
Automatically releases the memory.
bool is_owned() const
Returns if this process owns this memory and is responsible to delete it.
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
key_t get_shmkey() const
Returns the key of this shared memory.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
friend std::ostream & operator<<(std::ostream &o, const SharedMemory &v)
#define CXX11_NOEXCEPT
Used in public headers in place of "noexcept" of C++11.
char * get_block() const
Returns the memory block.
Brings error stacktrace information as return value of functions.
Represents memory shared between processes.
int get_numa_node() const
Where the physical memory is allocated.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
SharedMemory() noexcept
Empty constructor which allocates nothing.
void attach(const std::string &meta_path, bool use_hugepages)
Attach an already-allocated shared memory so that this object points to the memory.
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
const std::string & get_meta_path() const
Returns the path of the meta file.
int get_shmid() const
Returns the ID of this shared memory.
void mark_for_release()
Marks the shared memory as being removed so that it will be reclaimed when all processes detach it...
SharedMemory & operator=(const SharedMemory &other)=delete
bool is_null() const
Returns if this object doesn't hold a valid memory block.
ErrorStack alloc(const std::string &meta_path, uint64_t size, int numa_node, bool use_hugepages)
Newly allocate a shared memory of given size on given NUMA node.
pid_t get_owner_pid() const
If non-zero, it means the ID of the process that allocated the shared memory.
uint64_t get_size() const
Returns the byte size of the memory block.
void release_block()
Releases the memory block IF this process has an ownership.