32#ifndef __STATEOS_JOB_H
33#define __STATEOS_JOB_H
48typedef struct __job job_t;
62typedef struct __job job_id [];
80#define _JOB_INIT( _limit, _data ) { _OBJ_INIT(), 0, _limit, 0, 0, _data }
98#define _JOB_DATA( _limit ) (fun_t *[_limit]){ NULL }
108#define OS_JOB_BUFFER( buf, size ) \
118#define OS_JOB( job, limit ) \
119 static fun_t *job##__buf[limit]; \
120 job_t job[] = { _JOB_INIT( limit, job##__buf ) }
123#define static_JOB( job, limit ) \
124 static fun_t *job##__buf[limit]; \
125 static job_t job[] = { _JOB_INIT( limit, job##__buf ) }
138#define JOB_INIT( limit ) \
139 _JOB_INIT( limit, _JOB_DATA( limit ) )
153#define JOB_CREATE( limit ) \
154 { JOB_INIT ( limit ) }
473#if defined(__cplusplus) && (__cplusplus >= 201103L) && !defined(__STATEOS_STDCXX)
483template<
unsigned limit_>
488 JobQueueT(): __job _JOB_INIT(limit_, data_) {}
490 ~JobQueueT() { assert(__job::obj.queue ==
nullptr); }
495 assert(_src.__job::count == 0 && _src.obj.queue ==
nullptr);
536#if __cplusplus >= 201402L
537 using Ptr = std::unique_ptr<JobQueueT<limit_>>;
558 job->__job::obj.res = job;
563 fun_t *data_[limit_];
#define INFINITE
infinite waiting
Definition osbase.h:261
void fun_t(void)
timer/task procedure
Definition osbase.h:137
void job_pushISR(job_t *job, fun_t *fun)
ISR alias of job_push().
Definition osjobqueue.h:413
unsigned job_countISR(job_t *job)
ISR alias of job_count().
Definition osjobqueue.h:430
int job_sendFor(job_t *job, fun_t *fun, cnt_t delay)
try to transfer job data to the job queue object, wait for given duration of time while the job queue...
int job_waitUntil(job_t *job, cnt_t time)
try to transfer job data from the job queue object and execute the job procedure, wait until given ti...
int job_tryWait(job_t *job)
alias of job_take()
Definition osjobqueue.h:238
unsigned job_count(job_t *job)
return the amount of data contained in the job queue
int job_wait(job_t *job)
try to transfer job data from the job queue object and execute the job procedure, wait indefinitely w...
Definition osjobqueue.h:302
int job_giveISR(job_t *job, fun_t *fun)
ISR alias of job_give().
Definition osjobqueue.h:328
job_t * job_new(unsigned limit)
alias of job_create()
Definition osjobqueue.h:190
int job_takeAsync(job_t *job)
Async alias of job_take().
unsigned job_spaceISR(job_t *job)
ISR alias of job_space().
Definition osjobqueue.h:447
int job_sendAsync(job_t *job, fun_t *fun)
Async alias of job_send().
unsigned job_limitISR(job_t *job)
ISR alias of job_limit().
Definition osjobqueue.h:464
void job_push(job_t *job, fun_t *fun)
transfer job data to the job queue object, remove the oldest job data if the job queue object is full
void job_kill(job_t *job)
alias of job_reset()
Definition osjobqueue.h:204
int job_giveAsync(job_t *job, fun_t *fun)
Async alias of job_give().
void job_init(job_t *job, fun_t **data, size_t bufsize)
initialize a job queue object
unsigned job_limit(job_t *job)
return the size of the job queue
unsigned job_space(job_t *job)
return the amount of free space in the job queue
int job_give(job_t *job, fun_t *fun)
try to transfer job data to the job queue object, don't wait if the job queue object is full
int job_waitFor(job_t *job, cnt_t delay)
try to transfer job data from the job queue object and execute the job procedure, wait for given dura...
int job_take(job_t *job)
try to transfer job data from the job queue object and execute the job procedure, don't wait if the j...
void job_destroy(job_t *job)
reset the job queue object, wake up all waiting tasks with 'E_DELETED' event value and free allocated...
int job_takeISR(job_t *job)
ISR alias of job_take().
Definition osjobqueue.h:242
job_t * job_create(unsigned limit)
create and initialize a new job queue object
int job_send(job_t *job, fun_t *fun)
try to transfer job data to the job queue object, wait indefinitely while the job queue object is ful...
Definition osjobqueue.h:391
void job_delete(job_t *job)
alias of job_destroy()
Definition osjobqueue.h:218
void job_reset(job_t *job)
reset the job queue object and wake up all waiting tasks with 'E_STOPPED' event
int job_waitAsync(job_t *job)
Async alias of job_wait().
int job_sendUntil(job_t *job, fun_t *fun, cnt_t time)
try to transfer job data to the job queue object, wait until given timepoint while the job queue obje...
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 a job queue object
Definition osjobqueue.h:484
unsigned limit()
job_limit()
Definition osjobqueue.h:526
int tryWait()
job_tryWait()
Definition osjobqueue.h:506
unsigned limitISR()
job_limitISR()
Definition osjobqueue.h:527
void kill()
job_kill()
Definition osjobqueue.h:503
int waitAsync()
job_waitAsync()
Definition osjobqueue.h:530
int giveAsync(fun_t *_fun)
job_giveAsync()
Definition osjobqueue.h:531
unsigned spaceISR()
job_spaceISR()
Definition osjobqueue.h:525
std::unique_ptr< JobQueueT< limit_ > > Ptr
result type of Create()
Definition osjobqueue.h:536
int takeISR()
job_takeISR()
Definition osjobqueue.h:507
void reset()
job_reset()
Definition osjobqueue.h:502
int wait()
job_wait()
Definition osjobqueue.h:512
int sendAsync(fun_t *_fun)
job_sendAsync()
Definition osjobqueue.h:532
void pushISR(fun_t *_fun)
job_pushISR()
Definition osjobqueue.h:521
int takeAsync()
job_takeAsync()
Definition osjobqueue.h:529
unsigned count()
job_count()
Definition osjobqueue.h:522
static Ptr Create()
create dynamic object with manageable resources
Definition osjobqueue.h:553
constexpr JobQueueT()
constructor, see the constructor parameters of the class
Definition osjobqueue.h:487
unsigned countISR()
job_countISR()
Definition osjobqueue.h:523
void push(fun_t *_fun)
job_push()
Definition osjobqueue.h:520
int give(fun_t *_fun)
job_give()
Definition osjobqueue.h:513
void destroy()
job_destroy()
Definition osjobqueue.h:504
int sendFor(fun_t *_fun, const T &_delay)
job_sendFor()
Definition osjobqueue.h:516
int send(fun_t *_fun)
job_send()
Definition osjobqueue.h:519
int sendUntil(fun_t *_fun, const T &_time)
job_sendUntil()
Definition osjobqueue.h:518
int waitFor(const T &_delay)
job_waitFor()
Definition osjobqueue.h:509
unsigned space()
job_space()
Definition osjobqueue.h:524
int take()
job_take()
Definition osjobqueue.h:505
int waitUntil(const T &_time)
job_waitUntil()
Definition osjobqueue.h:511
int giveISR(fun_t *_fun)
job_giveISR()
Definition osjobqueue.h:514