odyssey/third_party/machinarium/sources/machine.h

44 lines
842 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;
struct mm_machine {
volatile int online;
uint64_t id;
char *name;
machine_coroutine_t main;
void *main_arg;
mm_thread_t thread;
void *thread_global_private;
mm_scheduler_t scheduler;
mm_signalmgr_t signal_mgr;
mm_eventmgr_t event_mgr;
mm_msgcache_t msg_cache;
mm_coroutine_cache_t coroutine_cache;
mm_loop_t loop;
mm_list_t link;
struct mm_tls_ctx *server_tls_ctx;
struct mm_tls_ctx *client_tls_ctx;
};
extern __thread mm_machine_t *mm_self;
static inline void mm_errno_set(int value)
2017-05-30 14:00:16 +00:00
{
mm_scheduler_current(&mm_self->scheduler)->errno_ = value;
}
static inline int mm_errno_get(void)
2017-05-30 14:00:16 +00:00
{
return mm_scheduler_current(&mm_self->scheduler)->errno_;
}
2017-05-24 11:04:19 +00:00
#endif /* MM_MACHINE_H */