21 #ifndef COSA_PROTO_THREAD_HH 22 #define COSA_PROTO_THREAD_HH 65 } __attribute__((packed));
115 __attribute__((always_inline))
127 __attribute__((always_inline))
137 __attribute__((always_inline))
160 virtual void on_run(uint8_t type, uint16_t value) = 0;
170 static uint16_t
dispatch(
bool flag =
true);
191 virtual void on_event(uint8_t type, uint16_t value);
198 #define PROTO_THREAD_BEGIN() \ 199 if (m_ip != 0) goto *m_ip 205 #define PROTO_THREAD_YIELD() \ 217 #define PROTO_THREAD_SLEEP() \ 219 m_state = SLEEPING; \ 221 PROTO_THREAD_YIELD(); \ 228 #define PROTO_THREAD_WAKE(thread) \ 230 if (thread->m_state == SLEEPING) \ 231 Thread::schedule(thread); \ 240 #define PROTO_THREAD_AWAIT(condition) \ 244 if (!(condition)) { \ 255 #define PROTO_THREAD_DELAY(ms) \ 258 PROTO_THREAD_AWAIT(timer_expired()); \ 265 #define PROTO_THREAD_END() \ 267 ProtoThread::end(); \
static void schedule(ProtoThread *thread)
bool timer_expired() const
int32_t expire_after() const
Detached. Need wakeup call.
static uint16_t dispatch(bool flag=true)
Timeout received and running.
virtual void on_event(uint8_t type, uint16_t value)
void set_timer(uint16_t ms)
virtual void on_run(uint8_t type, uint16_t value)=0
ProtoThread(Job::Scheduler *scheduler)