Adiar 2.1.0
An External Memory Decision Diagram Library
Loading...
Searching...
No Matches
memory.h
1#ifndef ADIAR_INTERNAL_MEMORY_H
2#define ADIAR_INTERNAL_MEMORY_H
3
4#include <string>
5
6#include <tpie/memory.h>
7#include <tpie/tpie.h>
8
9#include <adiar/internal/assert.h>
10
11namespace adiar::internal
12{
16 inline size_t
17 memory_available()
18 {
19 return tpie::get_memory_manager().available();
20 }
21
30 enum class memory_mode
31 {
32 Internal,
33 External
34 };
35}
36
37namespace adiar
38{
39 // TODO: add std::move(...) alias
40
41 // TODO: use TPIE allocation for `make_unique` and `make_shared`. This way we
42 // also account for the memory usage of each BDD.
43
44 // Based on <tpie/memory.h>
45
51 template <typename T>
52 using shared_ptr = std::shared_ptr<T>;
53
57 template <typename T, typename... TT>
58 inline shared_ptr<T>
60 {
61 return std::make_shared<T>(std::forward<TT>(tt)...);
62 }
63
69 template <typename T>
70 using unique_ptr = std::unique_ptr<T>;
71
75 template <typename T, typename... TT>
76 inline unique_ptr<T>
78 {
79 return std::make_unique<T>(std::forward<TT>(tt)...);
80 }
81}
82
83#endif // ADIAR_INTERNAL_MEMORY_H
consumer< ValueType > make_consumer(OutputIt &iter)
Wrap an iterator into a consumer function.
Definition functional.h:67
Core types.
Definition adiar.h:40
shared_ptr< T > make_shared(TT &&... tt)
Creates a new object on the heap with shared ownership.
Definition memory.h:59
std::unique_ptr< T > unique_ptr
Sole ownership of an object on the heap. Unlike the shared_ptr, this smart pointer has the semantics ...
Definition memory.h:70
unique_ptr< T > make_unique(TT &&... tt)
Creates a new object on the heap with unique ownership.
Definition memory.h:77
std::shared_ptr< T > shared_ptr
Shared ownership of an object on the heap. This smart pointer essentially provides a (thread-safe) re...
Definition memory.h:52