CACAO
Data Structures | Macros | Enumerations | Functions
thread.hpp File Reference

Go to the source code of this file.

Data Structures

struct  threadobject
 

Macros

#define DEBUGTHREADS(message, thread)
 
#define TRACEJAVACALLINDENT   (THREADOBJECT->tracejavacallindent)
 
#define TRACEJAVACALLCOUNT   (THREADOBJECT->tracejavacallcount)
 
#define FILTERVERBOSECALLCTR   (THREADOBJECT->filterverbosecallctr)
 
#define THREAD_NATIVEWORLD_ENTER   /*nop*/
 
#define THREAD_NATIVEWORLD_EXIT   /*nop*/
 

Enumerations

enum  ThreadState {
  THREAD_STATE_NEW = 0, THREAD_STATE_RUNNABLE = 1, THREAD_STATE_BLOCKED = 2, THREAD_STATE_WAITING = 3,
  THREAD_STATE_TIMED_WAITING = 4, THREAD_STATE_TERMINATED = 5, THREAD_STATE_PARKED = 6, THREAD_STATE_TIMED_PARKED = 7
}
 
enum  ThreadFlag { THREAD_FLAG_JAVA = 0x01, THREAD_FLAG_INTERNAL = 0x02, THREAD_FLAG_DAEMON = 0x04, THREAD_FLAG_IN_NATIVE = 0x08 }
 
enum  SuspendReason {
  SUSPEND_REASON_NONE = 0, SUSPEND_REASON_JAVA = 1, SUSPEND_REASON_STOPWORLD = 2, SUSPEND_REASON_DUMP = 3,
  SUSPEND_REASON_JVMTI = 4
}
 
enum  ThreadPriority { MIN_PRIORITY = 1, NORM_PRIORITY = 5, MAX_PRIORITY = 10 }
 

Functions

static threadobjectthread_get_current (void)
 
static java_handle_tthread_get_current_object (void)
 
static int cacaothread_get_state (threadobject *t)
 
static bool thread_is_attached (threadobject *t)
 
static bool thread_is_daemon (threadobject *t)
 
static bool thread_current_is_attached (void)
 
static struct stackframeinfo_tthreads_get_current_stackframeinfo (void)
 
static void threads_set_current_stackframeinfo (struct stackframeinfo_t *sfi)
 
void threads_preinit (void)
 
void threads_init (void)
 
void thread_free (threadobject *t)
 
bool threads_thread_start_internal (Utf8String name, functionptr f)
 
void threads_thread_start (java_handle_t *object)
 
bool thread_attach_current_thread (JavaVMAttachArgs *vm_aargs, bool isdaemon)
 Attaches the current thread to the VM. More...
 
bool thread_attach_current_external_thread (JavaVMAttachArgs *vm_aargs, bool isdaemon)
 Attaches the current external thread to the VM. More...
 
bool thread_detach_current_thread (void)
 Detaches the current thread from the VM. More...
 
bool thread_detach_current_external_thread (void)
 Detaches the current external thread from the VM. More...
 
void thread_fprint_name (threadobject *t, FILE *stream)
 
void thread_print_info (threadobject *t)
 
intptr_t threads_get_current_tid (void)
 
intptr_t threads_get_tid (threadobject *)
 
void thread_set_state_runnable (threadobject *t)
 
void thread_set_state_waiting (threadobject *t)
 
void thread_set_state_timed_waiting (threadobject *t)
 
void thread_set_state_parked (threadobject *t)
 
void thread_set_state_timed_parked (threadobject *t)
 
void thread_set_state_terminated (threadobject *t)
 
threadobjectthread_get_thread (java_handle_t *h)
 
bool threads_thread_is_alive (threadobject *t)
 
bool thread_is_interrupted (threadobject *t)
 
void thread_set_interrupted (threadobject *t, bool interrupted)
 
void threads_thread_interrupt (threadobject *thread)
 
void threads_start_thread (threadobject *thread, functionptr function)
 
void threads_set_thread_priority (threadobject *t, int priority)
 
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)
 
void threads_sleep (int64_t millis, int32_t nanos)
 Sleep the current thread for the specified amount of time. More...
 
void threads_wait_with_timeout_relative (threadobject *t, s8 millis, s4 nanos)
 
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 *thread)
 Unpark the specified thread. More...
 
void threads_impl_preinit (void)
 
void threads_impl_init (void)
 
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_thread_start (threadobject *thread, functionptr f)
 
void threads_yield (void)
 
void thread_handle_set_priority (java_handle_t *th, int)
 
bool thread_handle_is_interrupted (java_handle_t *th)
 
void thread_handle_interrupt (java_handle_t *th)
 
int thread_handle_get_state (java_handle_t *th)
 

Macro Definition Documentation

#define DEBUGTHREADS (   message,
  thread 
)
Value:
do { \
printf("[Thread %-16s: ", message); \
printf("]\n"); \
} \
} while (0)
int opt_DebugThreads
Definition: options.cpp:175
JNIEnv jthread thread
Definition: jvmti.h:207
void thread_print_info(threadobject *t)
Definition: thread.cpp:650
#define printf(...)
Definition: ssa2.cpp:40

Definition at line 166 of file thread.hpp.

#define FILTERVERBOSECALLCTR   (THREADOBJECT->filterverbosecallctr)

Definition at line 198 of file thread.hpp.

#define THREAD_NATIVEWORLD_ENTER   /*nop*/

Definition at line 208 of file thread.hpp.

#define THREAD_NATIVEWORLD_EXIT   /*nop*/

Definition at line 209 of file thread.hpp.

#define TRACEJAVACALLCOUNT   (THREADOBJECT->tracejavacallcount)

Definition at line 191 of file thread.hpp.

#define TRACEJAVACALLINDENT   (THREADOBJECT->tracejavacallindent)

Definition at line 190 of file thread.hpp.

Enumeration Type Documentation

Enumerator
SUSPEND_REASON_NONE 
SUSPEND_REASON_JAVA 
SUSPEND_REASON_STOPWORLD 
SUSPEND_REASON_DUMP 
SUSPEND_REASON_JVMTI 

Definition at line 65 of file thread.hpp.

enum ThreadFlag
Enumerator
THREAD_FLAG_JAVA 
THREAD_FLAG_INTERNAL 
THREAD_FLAG_DAEMON 
THREAD_FLAG_IN_NATIVE 

Definition at line 58 of file thread.hpp.

Enumerator
MIN_PRIORITY 
NORM_PRIORITY 
MAX_PRIORITY 

Definition at line 75 of file thread.hpp.

Enumerator
THREAD_STATE_NEW 
THREAD_STATE_RUNNABLE 
THREAD_STATE_BLOCKED 
THREAD_STATE_WAITING 
THREAD_STATE_TIMED_WAITING 
THREAD_STATE_TERMINATED 
THREAD_STATE_PARKED 
THREAD_STATE_TIMED_PARKED 

Definition at line 47 of file thread.hpp.

Function Documentation

static int cacaothread_get_state ( threadobject t)
inlinestatic

Definition at line 243 of file thread.hpp.

bool thread_attach_current_external_thread ( JavaVMAttachArgs *  vm_aargs,
bool  isdaemon 
)

Attaches the current external thread to the VM.

This function is called by JNI's AttachCurrentThread.

Parameters
vm_aargsAttach arguments.
isdaemontrue if the attached thread should be a daemon thread.
Returns
true on success, false otherwise.

Definition at line 584 of file thread.cpp.

bool thread_attach_current_thread ( JavaVMAttachArgs *  vm_aargs,
bool  isdaemon 
)

Attaches the current thread to the VM.

Parameters
vm_aargsAttach arguments.
isdaemontrue if the attached thread should be a daemon thread.
Returns
true on success, false otherwise.

Definition at line 495 of file thread.cpp.

static bool thread_current_is_attached ( void  )
inlinestatic

Definition at line 301 of file thread.hpp.

bool thread_detach_current_external_thread ( void  )

Detaches the current external thread from the VM.

This function is called by JNI's DetachCurrentThread.

Returns
true on success, false otherwise.

Definition at line 603 of file thread.cpp.

bool thread_detach_current_thread ( void  )

Detaches the current thread from the VM.

Returns
true on success, false otherwise

Definition at line 86 of file thread-none.cpp.

void thread_fprint_name ( threadobject t,
FILE *  stream 
)

Definition at line 630 of file thread.cpp.

void thread_free ( threadobject t)

Definition at line 371 of file thread.cpp.

static threadobject* thread_get_current ( void  )
inlinestatic
static java_handle_t* thread_get_current_object ( void  )
inlinestatic

Definition at line 226 of file thread.hpp.

threadobject* thread_get_thread ( java_handle_t h)

Definition at line 874 of file thread.cpp.

int thread_handle_get_state ( java_handle_t th)

Definition at line 1012 of file thread.cpp.

void thread_handle_interrupt ( java_handle_t th)

Definition at line 995 of file thread.cpp.

bool thread_handle_is_interrupted ( java_handle_t th)

Definition at line 981 of file thread.cpp.

void thread_handle_set_priority ( java_handle_t th,
int   
)

Definition at line 964 of file thread.cpp.

static bool thread_is_attached ( threadobject t)
inlinestatic

Definition at line 262 of file thread.hpp.

static bool thread_is_daemon ( threadobject t)
inlinestatic

Definition at line 285 of file thread.hpp.

bool thread_is_interrupted ( threadobject t)

Definition at line 926 of file thread.cpp.

void thread_print_info ( threadobject t)

Definition at line 650 of file thread.cpp.

void thread_set_interrupted ( threadobject t,
bool  interrupted 
)

Definition at line 949 of file thread.cpp.

void thread_set_state_parked ( threadobject t)

Definition at line 812 of file thread.cpp.

void thread_set_state_runnable ( threadobject t)

Definition at line 754 of file thread.cpp.

void thread_set_state_terminated ( threadobject t)

Definition at line 848 of file thread.cpp.

void thread_set_state_timed_parked ( threadobject t)

Definition at line 831 of file thread.cpp.

void thread_set_state_timed_waiting ( threadobject t)

Definition at line 793 of file thread.cpp.

void thread_set_state_waiting ( threadobject t)

Definition at line 773 of file thread.cpp.

static struct stackframeinfo_t* threads_get_current_stackframeinfo ( void  )
static

Definition at line 313 of file thread.hpp.

intptr_t threads_get_current_tid ( void  )

Definition at line 722 of file thread.cpp.

intptr_t threads_get_tid ( threadobject )

Definition at line 392 of file thread-none.cpp.

void threads_impl_clear_heap_pointers ( threadobject t)

Definition at line 239 of file thread-none.cpp.

void threads_impl_init ( void  )

Definition at line 58 of file thread-none.cpp.

void threads_impl_preinit ( void  )

Definition at line 52 of file thread-none.cpp.

void threads_impl_thread_clear ( threadobject t)

Definition at line 258 of file thread-none.cpp.

void threads_impl_thread_reuse ( threadobject t)

Definition at line 298 of file thread-none.cpp.

void threads_impl_thread_start ( threadobject thread,
functionptr  f 
)

Definition at line 64 of file thread-none.cpp.

void threads_init ( void  )

Definition at line 164 of file thread.cpp.

void threads_join_all_threads ( void  )

Definition at line 253 of file thread-none.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 373 of file thread-none.cpp.

void threads_preinit ( void  )

Definition at line 84 of file thread.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 220 of file thread-none.cpp.

static void threads_set_current_stackframeinfo ( struct stackframeinfo_t sfi)
inlinestatic

Definition at line 318 of file thread.hpp.

void threads_set_thread_priority ( threadobject t,
int  priority 
)

Definition at line 77 of file thread-none.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 320 of file thread-none.cpp.

void threads_start_thread ( threadobject thread,
functionptr  function 
)
void threads_suspend_ack ( )

Acknowledges the suspension of the current thread.

Definition at line 248 of file thread-none.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 194 of file thread-none.cpp.

void threads_thread_interrupt ( threadobject thread)

Definition at line 305 of file thread-none.cpp.

bool threads_thread_is_alive ( threadobject t)

Definition at line 886 of file thread.cpp.

void threads_thread_start ( java_handle_t object)

Definition at line 445 of file thread.cpp.

bool threads_thread_start_internal ( Utf8String  name,
functionptr  f 
)

Definition at line 402 of file thread.cpp.

void threads_unpark ( threadobject t)

Unpark the specified thread.

Parameters
tThe thread to unpark.

Definition at line 380 of file thread-none.cpp.

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

Definition at line 362 of file thread-none.cpp.

void threads_yield ( void  )

Definition at line 386 of file thread-none.cpp.