resources.h
Include dependency graph for resources.h:
This graph shows which files directly or indirectly include resources.h:
Private data structures for nif object resources.
Defines
-
TYPEDEF_GLOBALCONTEXT
-
SELECT_EVENT_NOTIFICATION_SIZE (TUPLE_SIZE(4) + REF_SIZE + TERM_BOXED_RESOURCE_SIZE)
Typedefs
-
typedef struct GlobalContext GlobalContext
Functions
-
static inline void resource_type_destroy(struct ResourceType *resource_type)
-
bool select_event_notify(ErlNifEvent event, bool is_read, bool is_write, GlobalContext *global)
Send a notification that an event was selected.
This function is called from sys_poll_events platform function if a select event was selected and the read or write flag was set. It modifies the select_event object so the notification is only sent once.
The function can also be called from a select task loop if
AVM_SELECT_IN_TASK
is defined.It is not an error to call this function with an event that is not in the list.
This function calls
sys_unregister_select_event
.- Parameters:
event – the event to notify
is_read – if the event was selected for reading
is_write – if the event was selected for writing
global – the global context
- Returns:
true if the event was found
-
void select_event_count_and_destroy_closed(struct ListHead *select_events, size_t *read, size_t *write, size_t *either, GlobalContext *global)
Count events available for reading and/or writing and destroy the events marked for close.
Convenience function that can be called by
sys_poll_events
and iterates on events to be closed and count them.The function can also be called from a select task loop if
AVM_SELECT_IN_TASK
is defined.- Parameters:
select_events – list of events, with a write lock
read – on output number of events with read = 1, can be NULL
write – on output number of events with write = 1, can be NULL
either – on output number of events with either read = 1 or write = 1, can be NULL
global – the global context
-
void destroy_resource_monitors(struct RefcBinary *resource, GlobalContext *global)
Destroy monitors associated with a resource.
- Parameters:
resource – resource to destroy monitors for
global – the global context
-
term select_event_make_notification(void *rsrc_obj, uint64_t ref_ticks, bool is_write, Heap *heap)
Build a select event notification.
- Parameters:
rsrc_obj – the resource to build the notification for
ref_ticks – the reference or 0 if it’s undefined
is_write – if the notification is for a write or a read
heap – the heap to create the notification in, should have enough memory available (see SELECT_EVENT_NOTIFICATION_SIZE)
-
struct ResourceType
- #include <resources.h>
Collaboration diagram for ResourceType:
A resource type.
we need a reference to the global context as
enif_release_resource
needs to access the synchronized list of refc_binaries
-
struct SelectEvent
- #include <resources.h>
Collaboration diagram for SelectEvent:
A selectable event.