Simple coroutine library integrated with IO event loop (libevent) / objects in plain C Snapshot
|
user mode thread attached to an event loop The thread owns one or more EVSOCKETS, it initially activated when the thread is created, and is futher activated when an IO event occurs on a EVSOCKET object owned by this thread. More...
Classes | |
struct | tagEVTHREAD |
Typedefs | |
typedef void(* | EVTHREAD_PROC )(struct tagEVTHREAD *thread, struct tagEVSOCKET *socket, void *user_ctx) |
typedef struct tagEVTHREAD | EVTHREAD |
Functions | |
EVTHREAD * | EVTHREAD_init (EVLOOP *loop, EVTHREAD_PROC thread_proc, void *user_ctx) |
int | EVTHREAD_start (EVTHREAD *thread, struct tagEVSOCKET *socket) |
int | EVTHREAD_delay (EVTHREAD *thread, struct timeval delay) |
user mode thread attached to an event loop The thread owns one or more EVSOCKETS, it initially activated when the thread is created, and is futher activated when an IO event occurs on a EVSOCKET object owned by this thread.
typedef struct tagEVTHREAD EVTHREAD |
typedef void(* EVTHREAD_PROC)(struct tagEVTHREAD *thread, struct tagEVSOCKET *socket, void *user_ctx) |
Definition at line 69 of file evthread.h.
int EVTHREAD_delay | ( | EVTHREAD * | thread, |
struct timeval | delay | ||
) |
Definition at line 110 of file evthread.c.
{ event_set( &thread->timer_event, -1, 0, thread_timer_cb, (void *) thread ); event_base_set( thread->loop->ev_base, &thread->timer_event ); event_add( &thread->timer_event, &delay ); CTHREAD_yield( 0, 0); event_del( &thread->timer_event ); return 0; }
EVTHREAD* EVTHREAD_init | ( | EVLOOP * | loop, |
EVTHREAD_PROC | thread_proc, | ||
void * | user_ctx | ||
) |
Definition at line 79 of file evthread.c.
{ EVTHREAD *thread; thread = (EVTHREAD *) malloc( sizeof( EVTHREAD ) ); if (!thread) { return 0; } thread->loop = loop; thread->thread_proc = thread_proc; thread->user_context = user_ctx; thread->cthread = CTHREAD_init( loop->stacks, evthread_proc ); if (!thread->cthread) { free(thread); return 0; } thread->socket = 0; DLIST_init( &thread->object_list ); return thread; }
int EVTHREAD_start | ( | EVTHREAD * | thread, |
struct tagEVSOCKET * | socket | ||
) |
Definition at line 103 of file evthread.c.