mirror of https://github.com/yandex/odyssey.git
35 lines
593 B
C
35 lines
593 B
C
|
|
/*
|
|
* machinarium.
|
|
*
|
|
* cooperative multitasking engine.
|
|
*/
|
|
|
|
#include <machinarium.h>
|
|
#include <machinarium_private.h>
|
|
|
|
int mm_thread_create(mm_thread_t *thread, mm_thread_function_t function, void *arg)
|
|
{
|
|
thread->function = function;
|
|
thread->arg = arg;
|
|
int rc;
|
|
rc = pthread_create(&thread->id, NULL, function, arg);
|
|
if (rc != 0)
|
|
return -1;
|
|
return 0;
|
|
}
|
|
|
|
int mm_thread_join(mm_thread_t *thread)
|
|
{
|
|
int rc;
|
|
rc = pthread_join(thread->id, NULL);
|
|
return rc;
|
|
}
|
|
|
|
int mm_thread_set_name(mm_thread_t *thread, char *name)
|
|
{
|
|
int rc;
|
|
rc = pthread_setname_np(thread->id, name);
|
|
return rc;
|
|
}
|