CACAO
Data Structures | Macros | Functions | Variables
thread-posix.cpp File Reference

Go to the source code of this file.

Data Structures

struct  startupinfo
 

Macros

#define __STDC_LIMIT_MACROS
 

Functions

static void threads_calc_absolute_time (struct timespec *tm, s8 millis, s4 nanos)
 
static void threads_set_thread_priority (pthread_t tid, int priority)
 
void threads_sem_init (sem_t *sem, bool shared, int value)
 
void threads_sem_wait (sem_t *sem)
 
void threads_sem_post (sem_t *sem)
 
void threads_impl_thread_clear (threadobject *t)
 
void threads_impl_thread_reuse (threadobject *t)
 
void threads_impl_clear_heap_pointers (threadobject *t)
 
void threads_impl_preinit (void)
 
void threads_impl_init (void)
 
static voidthreads_startup_thread (void *arg)
 
void threads_impl_thread_start (threadobject *thread, functionptr f)
 
void threads_set_thread_priority (threadobject *t, int priority)
 
bool thread_detach_current_thread (void)
 Detaches the current thread from the VM. More...
 
static void threads_suspend_self ()
 Internal helper function which suspends the current thread. More...
 
bool threads_suspend_thread (threadobject *thread, SuspendReason reason)
 Suspend the passed thread. More...
 
bool threads_resume_thread (threadobject *thread, SuspendReason reason)
 Resumes execution of the passed thread. More...
 
void threads_suspend_ack ()
 Acknowledges the suspension of the current thread. More...
 
void threads_join_all_threads (void)
 
static bool threads_timespec_earlier (const struct timespec *tv1, const struct timespec *tv2)
 
static bool threads_current_time_is_earlier_than (const struct timespec *tv)
 
static void threads_wait_with_timeout (threadobject *t, struct timespec *wakeupTime, bool parking)
 
void threads_wait_with_timeout_relative (threadobject *thread, s8 millis, s4 nanos)
 
void threads_thread_interrupt (threadobject *t)
 
void threads_sleep (int64_t millis, int32_t nanos)
 Sleep the current thread for the specified amount of time. More...
 
void threads_park (bool absolute, int64_t nanos)
 Park the current thread for the specified amount of time or until a specified deadline. More...
 
void threads_unpark (threadobject *t)
 Unpark the specified thread. More...
 
void threads_yield (void)
 
intptr_t threads_get_tid (threadobject *t)
 

Variables

__thread threadobjectthread_current
 
static Mutexstopworldlock
 
static Conditioncond_join
 

Macro Definition Documentation

#define __STDC_LIMIT_MACROS

Definition at line 25 of file thread-posix.cpp.

Function Documentation

bool thread_detach_current_thread ( void  )

Detaches the current thread from the VM.

Returns
true on success, false otherwise

Definition at line 839 of file thread-posix.cpp.

static void threads_calc_absolute_time ( struct timespec *  tm,
s8  millis,
s4  nanos 
)
static

Definition at line 1290 of file thread-posix.cpp.

static bool threads_current_time_is_earlier_than ( const struct timespec *  tv)
static

Definition at line 1172 of file thread-posix.cpp.

intptr_t threads_get_tid ( threadobject t)

Definition at line 1463 of file thread-posix.cpp.

void threads_impl_clear_heap_pointers ( threadobject t)

Definition at line 485 of file thread-posix.cpp.

void threads_impl_init ( void  )

Definition at line 557 of file thread-posix.cpp.

void threads_impl_preinit ( void  )

Definition at line 500 of file thread-posix.cpp.

void threads_impl_thread_clear ( threadobject t)

Definition at line 425 of file thread-posix.cpp.

void threads_impl_thread_reuse ( threadobject t)

Definition at line 478 of file thread-posix.cpp.

void threads_impl_thread_start ( threadobject thread,
functionptr  f 
)

Definition at line 740 of file thread-posix.cpp.

void threads_join_all_threads ( void  )

Definition at line 1113 of file thread-posix.cpp.

void threads_park ( bool  absolute,
int64_t  nanos 
)

Park the current thread for the specified amount of time or until a specified deadline.

Parameters
absoluteIs the time in nanos a deadline or a duration?
nanosNanoseconds to park (absolute=false) or deadline in milliseconds (absolute=true)

Definition at line 1414 of file thread-posix.cpp.

bool threads_resume_thread ( threadobject thread,
SuspendReason  reason 
)

Resumes execution of the passed thread.

Parameters
threadThe thread to be resumed.
reasonReason for suspending the given thread.
Returns
True of operation was successful, false otherwise.

Definition at line 1065 of file thread-posix.cpp.

void threads_sem_init ( sem_t *  sem,
bool  shared,
int  value 
)

Definition at line 204 of file thread-posix.cpp.

void threads_sem_post ( sem_t *  sem)

Definition at line 257 of file thread-posix.cpp.

void threads_sem_wait ( sem_t *  sem)

Definition at line 232 of file thread-posix.cpp.

static void threads_set_thread_priority ( pthread_t  tid,
int  priority 
)
static

Definition at line 823 of file thread-posix.cpp.

void threads_set_thread_priority ( threadobject t,
int  priority 
)

Definition at line 817 of file thread-posix.cpp.

void threads_sleep ( int64_t  millis,
int32_t  nanos 
)

Sleep the current thread for the specified amount of time.

Parameters
millisMilliseconds to sleep.
nanosNanoseconds to sleep.

Definition at line 1355 of file thread-posix.cpp.

static void* threads_startup_thread ( void arg)
static

Definition at line 597 of file thread-posix.cpp.

void threads_suspend_ack ( )

Acknowledges the suspension of the current thread.

Definition at line 1095 of file thread-posix.cpp.

static void threads_suspend_self ( )
static

Internal helper function which suspends the current thread.

This is the core method of the suspension mechanism actually blocking the execution until the suspension reason is cleared again. Note that the current thread needs to hold the suspension mutex while calling this function.

Definition at line 970 of file thread-posix.cpp.

bool threads_suspend_thread ( threadobject thread,
SuspendReason  reason 
)

Suspend the passed thread.

Execution of that thread stops until the thread is explicitly resumed again.

Parameters
threadThe thread to be suspended.
reasonReason for suspending the given thread.
Returns
True of operation was successful, false otherwise.

Definition at line 1018 of file thread-posix.cpp.

void threads_thread_interrupt ( threadobject t)

Definition at line 1327 of file thread-posix.cpp.

static bool threads_timespec_earlier ( const struct timespec *  tv1,
const struct timespec *  tv2 
)
inlinestatic

Definition at line 1151 of file thread-posix.cpp.

void threads_unpark ( threadobject t)

Unpark the specified thread.

Parameters
tThe thread to unpark.

Definition at line 1436 of file thread-posix.cpp.

static void threads_wait_with_timeout ( threadobject t,
struct timespec *  wakeupTime,
bool  parking 
)
static

Definition at line 1206 of file thread-posix.cpp.

void threads_wait_with_timeout_relative ( threadobject thread,
s8  millis,
s4  nanos 
)

Definition at line 1262 of file thread-posix.cpp.

void threads_yield ( void  )

Definition at line 1454 of file thread-posix.cpp.

Variable Documentation

Condition* cond_join
static

Definition at line 185 of file thread-posix.cpp.

Mutex* stopworldlock
static

Definition at line 177 of file thread-posix.cpp.

__thread threadobject* thread_current

Definition at line 171 of file thread-posix.cpp.