odyssey/src/mm_machine.h

41 lines
747 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_condition_cache_t condition_cache;
mm_loop_t loop;
mm_list_t link;
};
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 */