Nexus Embedded Platform 1.0.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
native.h
Go to the documentation of this file.
1
6#ifndef NEXUS_OS_NATIVE_H
7#define NEXUS_OS_NATIVE_H
8#include "nexus/os/wait.h"
9#include <pthread.h>
10#include <stddef.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
23typedef struct {
24 pthread_mutex_t mutex;
25 pthread_cond_t condition;
26 uint32_t sequence;
28 bool waiting;
30
37typedef struct {
38 pthread_mutex_t mutex;
39 pthread_cond_t readable;
40 pthread_cond_t writable;
41 uint8_t* bytes;
42 size_t depth;
43 size_t item_size;
44 size_t head;
45 size_t count;
46 size_t users;
47 bool closed;
50
58typedef struct {
59 pthread_t thread;
60 void (*entry)(void*);
61 void* context;
62 bool started;
64
69uint64_t nx_native_now_us(void);
104 size_t storage_bytes, size_t depth,
105 size_t item_size);
118 uint64_t deadline_us);
131 uint64_t deadline_us);
158 size_t stack_bytes, void (*entry)(void*),
159 void* context);
172
173#ifdef __cplusplus
174}
175#endif
176
177#endif /* NEXUS_OS_NATIVE_H */
nx_result_t nx_native_task_start(nx_native_task_t *task, void *stack, size_t stack_bytes, void(*entry)(void *), void *context)
Start a task using the supplied host stack.
nx_result_t nx_native_queue_close(nx_native_queue_t *queue)
Reject sends and wake all waiting callers.
nx_result_t nx_native_notify_destroy(nx_native_notify_t *notification)
Destroy after external publisher quiescence.
nx_result_t nx_native_queue_receive(nx_native_queue_t *queue, void *item, uint64_t deadline_us)
Receive one item; closed queues can still be drained.
nx_result_t nx_native_queue_send(nx_native_queue_t *queue, const void *item, uint64_t deadline_us)
Copy one item to the queue.
nx_result_t nx_native_notify_init(nx_native_notify_t *notification)
Initialize a notification in unused caller storage.
nx_result_t nx_native_task_join(nx_native_task_t *task)
Join after requesting cooperative application stop.
nx_wait_port_t nx_native_notify_port(nx_native_notify_t *notification)
Bind a single-waiter latched notification port.
uint64_t nx_native_now_us(void)
Read POSIX monotonic microseconds.
nx_result_t nx_native_queue_init(nx_native_queue_t *queue, void *storage, size_t storage_bytes, size_t depth, size_t item_size)
Initialize an explicit bounded byte-copy queue.
nx_result_t nx_native_queue_destroy(nx_native_queue_t *queue)
Destroy quiesced and drained queue storage.
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
Single waiter, multiple task publishers; fields are private.
Definition native.h:23
pthread_mutex_t mutex
Definition native.h:24
uint32_t sequence
Definition native.h:26
pthread_cond_t condition
Definition native.h:25
Caller-sized queue storage; no heap or global object pool.
Definition native.h:37
pthread_cond_t writable
Definition native.h:40
pthread_cond_t readable
Definition native.h:39
size_t item_size
Definition native.h:43
pthread_mutex_t mutex
Definition native.h:38
uint8_t * bytes
Definition native.h:41
Explicit task handle; stack storage is supplied at start.
Definition native.h:58
pthread_t thread
Definition native.h:59
void(* entry)(void *)
Definition native.h:60
void * context
Definition native.h:61
Single-waiter notification port.
Definition wait.h:42
Optional sequence-latched waiting without hidden workers.