2017-05-24 11:04:19 +00:00
|
|
|
#ifndef MM_MACHINE_H
|
|
|
|
#define MM_MACHINE_H
|
2017-05-17 11:49:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* machinarium.
|
|
|
|
*
|
|
|
|
* cooperative multitasking engine.
|
2020-04-02 11:00:56 +00:00
|
|
|
*/
|
2017-05-17 11:49:52 +00:00
|
|
|
|
2017-05-24 11:04:19 +00:00
|
|
|
typedef struct mm_machine mm_machine_t;
|
2017-05-17 11:49:52 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
struct mm_machine {
|
2020-04-02 11:00:56 +00:00
|
|
|
volatile int online;
|
|
|
|
uint64_t id;
|
|
|
|
char *name;
|
|
|
|
machine_coroutine_t main;
|
|
|
|
void *main_arg;
|
|
|
|
mm_thread_t thread;
|
2021-01-23 13:49:54 +00:00
|
|
|
void *thread_global_private;
|
2020-04-02 11:00:56 +00:00
|
|
|
mm_scheduler_t scheduler;
|
|
|
|
mm_signalmgr_t signal_mgr;
|
|
|
|
mm_eventmgr_t event_mgr;
|
|
|
|
mm_msgcache_t msg_cache;
|
2018-11-19 14:52:37 +00:00
|
|
|
mm_coroutine_cache_t coroutine_cache;
|
2020-04-02 11:00:56 +00:00
|
|
|
mm_loop_t loop;
|
|
|
|
mm_list_t link;
|
|
|
|
struct mm_tls_ctx *server_tls_ctx;
|
|
|
|
struct mm_tls_ctx *client_tls_ctx;
|
2017-05-17 11:49:52 +00:00
|
|
|
};
|
|
|
|
|
2017-05-17 14:20:04 +00:00
|
|
|
extern __thread mm_machine_t *mm_self;
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
static inline void mm_errno_set(int value)
|
2017-05-30 14:00:16 +00:00
|
|
|
{
|
|
|
|
mm_scheduler_current(&mm_self->scheduler)->errno_ = value;
|
|
|
|
}
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
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 */
|