refc_binary.h
Include dependency graph for refc_binary.h:
This graph shows which files directly or indirectly include refc_binary.h:
Defines
-
ATOMIC
-
TYPEDEF_CONTEXT
-
TYPEDEF_GLOBALCONTEXT
Functions
-
struct RefcBinary *refc_binary_create_resource(size_t size, struct ResourceType *resource_type)
Create a reference-counted resource object outside of the process heap.
This function will create a reference-counted resource object outside of the context heap. A blob will be allocated in the VM memory (e.g., via malloc). The allocated data will include an internal data structure that includes the data size and reference count.
- Parameters:
size – the size of the data to create
resource_type – the resource type,
NULL
for regular refc binaries.
- Returns:
a pointer to the out-of-context data.
-
static inline struct RefcBinary *refc_binary_create_refc(size_t size)
Create a reference-counted binary outside of the process heap.
This function will create a reference-counted binary outside of the context heap. A blob will be allocated in the VM memory (e.g., via malloc). The allocated data will include an internal data structure that includes the data size and reference count.
- Parameters:
size – the size of the data to create
- Returns:
a pointer to the out-of-context data.
-
const char *refc_binary_get_data(const struct RefcBinary *ptr)
get the data of the off-context binary
Return the data of the off-context binary
- Parameters:
ptr – Refc binary returned from memory_create_refc_binary
-
struct RefcBinary *refc_binary_from_data(void *ptr)
get the refc binary from its pointer
This must only be passed the result of
refc_binary_get_data
.- Parameters:
ptr – pointer obtained from
refc_binary_get_data
-
void refc_binary_increment_refcount(struct RefcBinary *ptr)
Increment the reference count on the refc binary.
- Parameters:
ptr – the refc binary
-
bool refc_binary_decrement_refcount(struct RefcBinary *ptr, GlobalContext *global)
Decrement the reference count on the refc binary.
This function will call
refc_binary_destroy
if the reference count reaches 0.- Parameters:
ptr – the refc binary
global – the global context
- Returns:
true if the refc binary was free’d; false, otherwise
-
void refc_binary_destroy(struct RefcBinary *refc, struct GlobalContext *global)
Destroy a refc binary after its reference count reached 0.
This function will call the destructor if the refc binary is a resource and will free the refc binary.
- Parameters:
refc – the binary to destroy
global – the global context
-
term refc_binary_create_binary_info(Context *ctx)
TODO consider implementing erlang:memory/0,1 instead
-
size_t refc_binary_total_size(Context *ctx)
Return the total size (in bytes) of all reference counted binaries.
- Returns:
the total size (in bytes) of all reference counted binaries
-
struct RefcBinary
- #include <refc_binary.h>
Collaboration diagram for RefcBinary: