odyssey/third_party/machinarium/sources/machine.h

46 lines
929 B
C
Raw Normal View History

2017-05-24 11:04:19 +00:00
#ifndef MM_MACHINE_H
#define MM_MACHINE_H
/*
* machinarium.
*
* cooperative multitasking engine.
*/
2017-05-24 11:04:19 +00:00
typedef struct mm_machine mm_machine_t;
2017-05-24 11:04:19 +00:00
struct mm_machine
{
2017-05-27 12:23:06 +00:00
int online;
uint64_t id;
char *name;
machine_coroutine_t main;
2017-05-27 12:23:06 +00:00
void *main_arg;
mm_thread_t thread;
mm_scheduler_t scheduler;
mm_signalmgr_t signal_mgr;
2017-06-06 13:11:59 +00:00
mm_eventmgr_t event_mgr;
mm_msgcache_t msg_cache;
mm_coroutine_cache_t coroutine_cache;
2017-05-27 12:23:06 +00:00
mm_loop_t loop;
mm_list_t link;
2020-02-22 19:50:48 +00:00
struct mm_tls_ctx *server_tls_ctx;
struct mm_tls_ctx *client_tls_ctx;
};
extern __thread mm_machine_t *mm_self;
2017-05-30 14:00:16 +00:00
static inline void
mm_errno_set(int value)
{
mm_scheduler_current(&mm_self->scheduler)->errno_ = value;
}
static inline int
mm_errno_get(void)
{
return mm_scheduler_current(&mm_self->scheduler)->errno_;
}
2017-05-24 11:04:19 +00:00
#endif /* MM_MACHINE_H */