32#ifndef __STATEOS_EVQ_H
33#define __STATEOS_EVQ_H
48typedef struct __evq evq_t;
62typedef struct __evq evq_id [];
80#define _EVQ_INIT( _limit, _data ) { _OBJ_INIT(), 0, _limit, 0, 0, _data }
98#define _EVQ_DATA( _limit ) (unsigned[_limit]){ 0 }
108#define OS_EVQ_BUFFER( buf, limit ) \
118#define OS_EVQ( evq, limit ) \
119 static unsigned evq##__buf[limit]; \
120 evq_t evq[] = { _EVQ_INIT( limit, evq##__buf ) }
123#define static_EVQ( evq, limit ) \
124 static unsigned evq##__buf[limit]; \
125 static evq_t evq[] = { _EVQ_INIT( limit, evq##__buf ) }
138#define EVQ_INIT( limit ) \
139 _EVQ_INIT( limit, _EVQ_DATA( limit ) )
153#define EVQ_CREATE( limit ) \
154 { EVQ_INIT ( limit ) }
174void evq_init( evq_t *evq,
unsigned *
data,
size_t bufsize );
236int evq_take( evq_t *evq,
unsigned *event );
269int evq_waitFor( evq_t *evq,
unsigned *event, cnt_t delay );
329int evq_give( evq_t *evq,
unsigned event );
358int evq_sendFor( evq_t *evq,
unsigned event, cnt_t delay );
414void evq_push( evq_t *evq,
unsigned event );
477#if defined(__cplusplus) && (__cplusplus >= 201103L) && !defined(__STATEOS_STDCXX)
487template<
unsigned limit_>
499 assert(_src.__evq::count == 0 && _src.obj.queue ==
nullptr);
510 int take (
unsigned *_event =
nullptr ) {
return evq_take (
this, _event); }
519 int wait (
unsigned *_event =
nullptr ) {
return evq_wait (
this, _event); }
545#if __cplusplus >= 201402L
546 using Ptr = std::unique_ptr<EventQueueT<limit_>>;
567 evq->__evq::obj.res = evq;
572 unsigned data_[limit_];
#define INFINITE
infinite waiting
Definition osbase.h:261
int evq_give(evq_t *evq, unsigned event)
try to transfer event value to the event queue object, don't wait if the event queue object is full
unsigned evq_limitISR(evq_t *evq)
ISR alias of evq_limit().
Definition oseventqueue.h:468
void evq_push(evq_t *evq, unsigned event)
transfer event value to the event queue object, remove the oldest event value if the event queue obje...
void evq_init(evq_t *evq, unsigned *data, size_t bufsize)
initialize an event queue object
int evq_tryWait(evq_t *evq, unsigned *event)
alias of evq_take()
Definition oseventqueue.h:239
int evq_waitUntil(evq_t *evq, unsigned *event, cnt_t time)
try to transfer event value from the event queue object, wait until given timepoint while the event q...
int evq_sendFor(evq_t *evq, unsigned event, cnt_t delay)
try to transfer event value to the event queue object, wait for given duration of time while the even...
evq_t * evq_new(unsigned limit)
alias of evq_create()
Definition oseventqueue.h:190
void evq_kill(evq_t *evq)
alias of evq_reset()
Definition oseventqueue.h:204
int evq_giveAsync(evq_t *evq, unsigned event)
Async alias of evq_give().
int evq_wait(evq_t *evq, unsigned *event)
try to transfer event value from the event queue object, wait indefinitely while the event queue obje...
Definition oseventqueue.h:306
unsigned evq_spaceISR(evq_t *evq)
ISR alias of evq_space().
Definition oseventqueue.h:451
unsigned evq_space(evq_t *evq)
return the amount of free space in the event queue
int evq_waitFor(evq_t *evq, unsigned *event, cnt_t delay)
try to transfer event value from the event queue object, wait for given duration of time while the ev...
unsigned evq_count(evq_t *evq)
return the amount of data contained in the event queue
void evq_delete(evq_t *evq)
alias of evq_destroy()
Definition oseventqueue.h:218
void evq_reset(evq_t *evq)
reset the event queue object and wake up all waiting tasks with 'E_STOPPED' event value
int evq_giveISR(evq_t *evq, unsigned event)
ISR alias of evq_give().
Definition oseventqueue.h:332
void evq_pushISR(evq_t *evq, unsigned event)
ISR alias of evq_push().
Definition oseventqueue.h:417
int evq_sendAsync(evq_t *evq, unsigned event)
Async alias of evq_send().
int evq_sendUntil(evq_t *evq, unsigned event, cnt_t time)
try to transfer event value to the event queue object, wait until given timepoint while the event que...
int evq_send(evq_t *evq, unsigned event)
try to transfer event value to the event queue object, wait indefinitely while the event queue object...
Definition oseventqueue.h:395
int evq_take(evq_t *evq, unsigned *event)
try to transfer event value from the event queue object, don't wait if the event queue object is empt...
int evq_takeAsync(evq_t *evq, unsigned *event)
Async alias of evq_take().
void evq_destroy(evq_t *evq)
reset the event queue object, wake up all waiting tasks with 'E_DELETED' event value and free allocat...
int evq_takeISR(evq_t *evq, unsigned *event)
ISR alias of evq_take().
Definition oseventqueue.h:243
unsigned evq_limit(evq_t *evq)
return the size of the event queue
evq_t * evq_create(unsigned limit)
create and initialize a new event queue object
int evq_waitAsync(evq_t *evq, unsigned *event)
Async alias of evq_wait().
unsigned evq_countISR(evq_t *evq)
ISR alias of evq_count().
Definition oseventqueue.h:434
char data[]
message data
Definition osmessagequeue.h:54
static constexpr rep count(const std::chrono::duration< _Rep, _Period > &_delay)
delay in ticks, rounded up to whole ticks; negative delay: IMMEDIATE, delay out of range: INFINITE
Definition osclock.h:109
static constexpr rep until(const std::chrono::time_point< Clock, _Duration > &_time)
time point in ticks, rounded up to whole ticks (only a time point of this clock)
Definition osclock.h:116
create and initialize an event queue object
Definition oseventqueue.h:488
int send(unsigned _event)
evq_send()
Definition oseventqueue.h:526
int take(unsigned &_event)
evq_take()
Definition oseventqueue.h:510
unsigned space()
evq_space()
Definition oseventqueue.h:531
constexpr EventQueueT()
constructor, see the constructor parameters of the class
Definition oseventqueue.h:491
unsigned limitISR()
evq_limitISR()
Definition oseventqueue.h:534
int giveISR(unsigned _event)
evq_giveISR()
Definition oseventqueue.h:521
void reset()
evq_reset()
Definition oseventqueue.h:506
unsigned spaceISR()
evq_spaceISR()
Definition oseventqueue.h:532
void destroy()
evq_destroy()
Definition oseventqueue.h:508
int takeAsync(unsigned &_event)
evq_takeAsync()
Definition oseventqueue.h:537
int takeISR(unsigned *_event)
evq_takeISR()
Definition oseventqueue.h:513
void kill()
evq_kill()
Definition oseventqueue.h:507
unsigned count()
evq_count()
Definition oseventqueue.h:529
int sendAsync(unsigned _event)
evq_sendAsync()
Definition oseventqueue.h:541
std::unique_ptr< EventQueueT< limit_ > > Ptr
result type of Create()
Definition oseventqueue.h:545
int take(unsigned *_event=nullptr)
evq_take()
Definition oseventqueue.h:509
unsigned limit()
evq_limit()
Definition oseventqueue.h:533
int waitFor(unsigned *_event, const T &_delay)
evq_waitFor()
Definition oseventqueue.h:515
int wait(unsigned *_event=nullptr)
evq_wait()
Definition oseventqueue.h:518
int tryWait(unsigned *_event=nullptr)
evq_tryWait()
Definition oseventqueue.h:511
int wait(unsigned &_event)
evq_wait()
Definition oseventqueue.h:519
int tryWait(unsigned &_event)
evq_tryWait()
Definition oseventqueue.h:512
void pushISR(unsigned _event)
evq_pushISR()
Definition oseventqueue.h:528
int waitUntil(unsigned *_event, const T &_time)
evq_waitUntil()
Definition oseventqueue.h:517
int sendFor(unsigned _event, const T &_delay)
evq_sendFor()
Definition oseventqueue.h:523
static Ptr Create()
create dynamic object with manageable resources
Definition oseventqueue.h:562
void push(unsigned _event)
evq_push()
Definition oseventqueue.h:527
int takeAsync(unsigned *_event=nullptr)
evq_takeAsync()
Definition oseventqueue.h:536
int waitAsync(unsigned &_event)
evq_waitAsync()
Definition oseventqueue.h:539
int give(unsigned _event)
evq_give()
Definition oseventqueue.h:520
int giveAsync(unsigned _event)
evq_giveAsync()
Definition oseventqueue.h:540
int waitAsync(unsigned *_event=nullptr)
evq_waitAsync()
Definition oseventqueue.h:538
int sendUntil(unsigned _event, const T &_time)
evq_sendUntil()
Definition oseventqueue.h:525
unsigned countISR()
evq_countISR()
Definition oseventqueue.h:530