include/empthread.h File Reference

#include <time.h>

Include dependency graph for empthread.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int empth_init (void **ctx, int flags)
empth_tempth_create (void(*entry)(void *), int size, int flags, char *name, void *ud)
empth_tempth_self (void)
void empth_exit (void)
void empth_yield (void)
void empth_terminate (empth_t *thread)
void empth_select (int fd, int flags)
void empth_wakeup (empth_t *thread)
int empth_sleep (time_t until)
int empth_wait_for_signal (void)
empth_rwlock_tempth_rwlock_create (char *name)
void empth_rwlock_destroy (empth_rwlock_t *rwlock)
void empth_rwlock_wrlock (empth_rwlock_t *rwlock)
void empth_rwlock_rdlock (empth_rwlock_t *rwlock)
void empth_rwlock_unlock (empth_rwlock_t *rwlock)
void empth_init_signals (void)


Function Documentation

empth_t* empth_create ( void(*)(void *)  entry,
int  size,
int  flags,
char *  name,
void *  ud 
)

Definition at line 63 of file lwp.c.

References empth_start(), empth_status(), empth_yield(), empth_t::ep, logerror(), empth_t::name, NULL, empth_t::state, and empth_t::ud.

Referenced by market_init(), player_accept(), shutdown_initiate(), start_server(), and update_init().

00065 {
00066     if (!flags)
00067         flags = empth_flags;
00068     return lwpCreate(1, entry, size, flags, name, 0, 0, ud);
00069 }

Here is the call graph for this function:

void empth_exit ( void   ) 

Definition at line 78 of file lwp.c.

References ctx_key, empth_status(), mtx_ctxsw, and empth_t::name.

Referenced by empth_restorectx(), empth_select(), empth_start(), empth_threadMain(), and player_login().

00079 {
00080     lwpExit();
00081 }

Here is the call graph for this function:

int empth_init ( void **  ctx,
int  flags 
)

Definition at line 47 of file lwp.c.

References ctx_key, empth_alarm(), empth_flags, empth_init_signals(), empth_t::ep, empth_t::id, logerror(), mtx_ctxsw, empth_t::name, NULL, sigaction::sa_flags, sigaction::sa_handler, empth_t::state, empth_t::ud, and udata.

Referenced by start_server().

00048 {
00049     sigset_t set;
00050 
00051     empth_flags = flags;
00052     empth_init_signals();
00053     sigemptyset(&set);
00054     sigaddset(&set, SIGHUP);
00055     sigaddset(&set, SIGINT);
00056     sigaddset(&set, SIGTERM);
00057     lwpInitSystem(1, ctx, flags, &set);
00058     return 0;
00059 }

Here is the call graph for this function:

void empth_init_signals ( void   ) 

Definition at line 45 of file posix.c.

References NULL, panic(), sigaction::sa_flags, and sigaction::sa_handler.

Referenced by empth_init().

00046 {
00047     struct sigaction act;
00048 
00049     act.sa_flags = 0;
00050     sigemptyset(&act.sa_mask);
00051     act.sa_handler = panic;
00052     sigaction(SIGBUS, &act, NULL);
00053     sigaction(SIGSEGV, &act, NULL);
00054     sigaction(SIGILL, &act, NULL);
00055     sigaction(SIGFPE, &act, NULL);
00056     act.sa_handler = SIG_IGN;
00057     sigaction(SIGPIPE, &act, NULL);
00058 }

Here is the call graph for this function:

empth_rwlock_t* empth_rwlock_create ( char *  name  ) 

Definition at line 136 of file lwp.c.

References NULL.

Referenced by update_init().

00137 {
00138     return lwp_rwlock_create(name);
00139 }

void empth_rwlock_destroy ( empth_rwlock_t rwlock  ) 

Definition at line 142 of file lwp.c.

References empth_rwlock_t::lock, and empth_rwlock_t::name.

00143 {
00144     lwp_rwlock_destroy(rwlock);
00145 }

void empth_rwlock_rdlock ( empth_rwlock_t rwlock  ) 

Definition at line 154 of file lwp.c.

References empth_restorectx(), empth_rwlock_t::lock, and mtx_ctxsw.

Referenced by dispatch().

00155 {
00156     lwp_rwlock_rdlock(rwlock);
00157 }

Here is the call graph for this function:

void empth_rwlock_unlock ( empth_rwlock_t rwlock  ) 

Definition at line 160 of file lwp.c.

References empth_rwlock_t::lock.

Referenced by dispatch(), and update_run().

00161 {
00162     lwp_rwlock_unlock(rwlock);
00163 }

void empth_rwlock_wrlock ( empth_rwlock_t rwlock  ) 

Definition at line 148 of file lwp.c.

References empth_restorectx(), empth_rwlock_t::lock, and mtx_ctxsw.

Referenced by shutdwn(), and update_run().

00149 {
00150     lwp_rwlock_wrlock(rwlock);
00151 }

Here is the call graph for this function:

void empth_select ( int  fd,
int  flags 
)

Definition at line 96 of file lwp.c.

References empth_exit(), empth_restorectx(), empth_status(), logerror(), and mtx_ctxsw.

Referenced by io_input(), io_output(), io_output_all(), and player_accept().

00097 {
00098     lwpSleepFd(fd, flags);
00099 }

Here is the call graph for this function:

empth_t* empth_self ( void   ) 

Definition at line 72 of file lwp.c.

References ctx_key.

Referenced by empth_status(), journal_entry(), market_update(), player_login(), and update_sched().

00073 {
00074     return LwpCurrent;
00075 }

int empth_sleep ( time_t  until  ) 

Definition at line 108 of file lwp.c.

References ctx_key, empth_restorectx(), empth_status(), mtx_ctxsw, and NULL.

Referenced by delete_lostitems(), market_update(), player_kill_idle(), shutdown_sequence(), and update_sched().

00109 {
00110     return lwpSleepUntil(until);
00111 }

Here is the call graph for this function:

void empth_terminate ( empth_t thread  ) 

Definition at line 90 of file lwp.c.

References EMPTH_KILLED, empth_status(), empth_t::id, empth_t::name, and empth_t::state.

00091 {
00092     lwpTerminate(a);
00093 }

Here is the call graph for this function:

int empth_wait_for_signal ( void   ) 

Definition at line 114 of file lwp.c.

References CANT_HAPPEN, empth_restorectx(), empth_status(), and mtx_ctxsw.

Referenced by main(), and service_main().

00115 {
00116     sigset_t set;
00117     int sig, err;
00118     time_t now;
00119 
00120     sigemptyset(&set);
00121     sigaddset(&set, SIGHUP);
00122     sigaddset(&set, SIGINT);
00123     sigaddset(&set, SIGTERM);
00124     for (;;) {
00125         err = lwpSigWait(&set, &sig);
00126         if (CANT_HAPPEN(err)) {
00127             time(&now);
00128             lwpSleepUntil(now + 60);
00129             continue;
00130         }
00131         return sig;
00132     }
00133 }

Here is the call graph for this function:

void empth_wakeup ( empth_t thread  ) 

Definition at line 102 of file lwp.c.

References EMPTH_INTR, empth_status(), empth_t::id, empth_t::name, and empth_t::state.

Referenced by player_kill_idle(), shutdwn(), update_reschedule(), update_run(), and update_trigger().

00103 {
00104     lwpWakeup(a);
00105 }

Here is the call graph for this function:

void empth_yield ( void   ) 

Definition at line 84 of file lwp.c.

References empth_restorectx(), and mtx_ctxsw.

Referenced by dispatch(), empth_create(), player_main(), and stre().

00085 {
00086     lwpYield();
00087 }

Here is the call graph for this function:


Generated on Fri Mar 28 11:01:21 2008 for empserver by  doxygen 1.5.2