CACAO
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ThreadList Class Reference

Public Member Functions

 ThreadList ()
 
Mutexmutex ()
 
void wait_cond (Condition *cond)
 
void add_to_active_thread_list (threadobject *t)
 
threadobjectget_main_thread ()
 
void get_free_thread (threadobject **t, int32_t *index)
 Get the next free thread object. More...
 
threadobjectget_thread_by_index (int32_t index)
 Return the thread object with the given index. More...
 
threadobjectget_thread_from_java_object (java_handle_t *h)
 Return the Java thread object from the given thread object. More...
 
void release_thread (threadobject *t, bool needs_deactivate)
 Release the thread. More...
 
void deactivate_thread (threadobject *t)
 
void get_active_threads (List< threadobject * > &list)
 Fills the passed list with all currently active threads. More...
 
void get_active_java_threads (List< threadobject * > &list)
 Fills the passed list with all currently active threads which should be visible to Java. More...
 
int32_t get_number_of_started_java_threads ()
 
int32_t get_number_of_active_java_threads ()
 
int32_t get_number_of_daemon_java_threads ()
 Return the number of daemon threads visible to Java. More...
 
int32_t get_peak_of_active_java_threads ()
 
void reset_peak_of_active_java_threads ()
 
int32_t get_number_of_active_threads ()
 
int32_t get_number_of_non_daemon_threads ()
 Return the number of non-daemon threads. More...
 
void dump_threads ()
 Dumps info for all threads running in the VM. More...
 

Static Public Member Functions

static void create_object ()
 Supposed to be called exactly once, early during initialization. More...
 
static ThreadListget ()
 Provides access to singleton. More...
 

Private Member Functions

void remove_from_active_thread_list (threadobject *t)
 

Private Attributes

Mutex _mutex
 
List< threadobject * > _active_thread_list
 
List< threadobject * > _free_thread_list
 
int32_t _number_of_started_java_threads
 
int32_t _number_of_active_java_threads
 
int32_t _peak_of_active_java_threads
 
int32_t _last_index
 

Static Private Attributes

static ThreadListthe_threadlist = 0
 

Detailed Description

Definition at line 38 of file threadlist.hpp.

Constructor & Destructor Documentation

ThreadList::ThreadList ( )
inline

Definition at line 97 of file threadlist.hpp.

Member Function Documentation

void ThreadList::add_to_active_thread_list ( threadobject t)
inline

Definition at line 111 of file threadlist.hpp.

void ThreadList::create_object ( )
inlinestatic

Supposed to be called exactly once, early during initialization.

Definition at line 105 of file threadlist.hpp.

void ThreadList::deactivate_thread ( threadobject t)

Definition at line 269 of file threadlist.cpp.

void ThreadList::dump_threads ( )

Dumps info for all threads running in the VM.

This function is called when SIGQUIT (<ctrl>-) is sent to the VM.

Definition at line 47 of file threadlist.cpp.

static ThreadList* ThreadList::get ( )
inlinestatic

Provides access to singleton.

Definition at line 62 of file threadlist.hpp.

void ThreadList::get_active_java_threads ( List< threadobject * > &  list)

Fills the passed list with all currently active threads which should be visible to Java.

Creating a copy of the thread list here, is the only way to ensure we do not end up in a dead-lock when iterating over the list.

Parameters
listlist class to be filled

Definition at line 111 of file threadlist.cpp.

void ThreadList::get_active_threads ( List< threadobject * > &  list)

Fills the passed list with all currently active threads.

Creating a copy of the thread list here, is the only way to ensure we do not end up in a dead-lock when iterating over the list.

Parameters
listlist class to be filled

Definition at line 95 of file threadlist.cpp.

void ThreadList::get_free_thread ( threadobject **  thread,
int32_t *  index 
)

Get the next free thread object.

Gets the next free thread object and a thread index for it. The results are stored into the passed pointers.

If no free thread is available `*thread' will contain NULL. `*index' will always, even if no free thread is available, contain a valid index you can use for a new thread.

Definition at line 138 of file threadlist.cpp.

threadobject * ThreadList::get_main_thread ( )
inline

Definition at line 139 of file threadlist.hpp.

int32_t ThreadList::get_number_of_active_java_threads ( )
inline

Definition at line 160 of file threadlist.hpp.

int32_t ThreadList::get_number_of_active_threads ( )
inline

Definition at line 146 of file threadlist.hpp.

int32_t ThreadList::get_number_of_daemon_java_threads ( void  )

Return the number of daemon threads visible to Java.

NOTE: This function does a linear-search over the threads list, because it is only used by the management interface.

Returns
number of daemon threads

Definition at line 164 of file threadlist.cpp.

int32_t ThreadList::get_number_of_non_daemon_threads ( void  )

Return the number of non-daemon threads.

NOTE: This function does a linear-search over the threads list, because it is only used for joining the threads.

Returns
number of non daemon threads

Definition at line 195 of file threadlist.cpp.

int32_t ThreadList::get_number_of_started_java_threads ( )
inline

Definition at line 153 of file threadlist.hpp.

int32_t ThreadList::get_peak_of_active_java_threads ( )
inline

Definition at line 167 of file threadlist.hpp.

threadobject * ThreadList::get_thread_by_index ( int32_t  index)

Return the thread object with the given index.

Returns
thread object

Definition at line 224 of file threadlist.cpp.

threadobject * ThreadList::get_thread_from_java_object ( java_handle_t h)

Return the Java thread object from the given thread object.

Returns
Java thread object

Definition at line 251 of file threadlist.cpp.

Mutex& ThreadList::mutex ( )
inline

Definition at line 64 of file threadlist.hpp.

void ThreadList::release_thread ( threadobject t,
bool  needs_deactivate 
)

Release the thread.

Returns
free thread index

Definition at line 282 of file threadlist.cpp.

void ThreadList::remove_from_active_thread_list ( threadobject t)
inlineprivate

Definition at line 126 of file threadlist.hpp.

void ThreadList::reset_peak_of_active_java_threads ( )
inline

Definition at line 174 of file threadlist.hpp.

void ThreadList::wait_cond ( Condition cond)
inline

Definition at line 66 of file threadlist.hpp.

Field Documentation

List<threadobject*> ThreadList::_active_thread_list
private

Definition at line 44 of file threadlist.hpp.

List<threadobject*> ThreadList::_free_thread_list
private

Definition at line 45 of file threadlist.hpp.

int32_t ThreadList::_last_index
private

Definition at line 53 of file threadlist.hpp.

Mutex ThreadList::_mutex
private

Definition at line 42 of file threadlist.hpp.

int32_t ThreadList::_number_of_active_java_threads
private

Definition at line 49 of file threadlist.hpp.

int32_t ThreadList::_number_of_started_java_threads
private

Definition at line 48 of file threadlist.hpp.

int32_t ThreadList::_peak_of_active_java_threads
private

Definition at line 50 of file threadlist.hpp.

ThreadList * ThreadList::the_threadlist = 0
staticprivate

Definition at line 40 of file threadlist.hpp.


The documentation for this class was generated from the following files: