nn::os::ManagedThread Class

Header file: nn/os.h

Syntax

class ManagedThread : 
    public nn::fnd::IntrusiveLinkedList::Item,
    public nn::util::NonCopyable< ManagedThread >

Description

Utility class with additional features to the standard Thread class.

Threads are handled basically the same way as with the Thread class, so for details see Thread. The one difference is that the process of creating threads is separated from the process of starting threads. To create threads, use a function like Initialize. To start the processing of a thread call Start.

Here is a list of the main features added:
・ Get information related to stacks.
・ Maintain names.
・ Get IDs faster by caching.
・ Get instance corresponding to current thread.
・ Enumerate threads.

A maximum of 32 threads can be created at the same time, and this restriction includes threads created with ManagedThread.

You need to call InitializeEnvironment before using this class. Calling this function consumes two ThreadLocalStorage objects.

Classes

nn::os::ManagedThread::EnumerateCallback Interface class for thread enumeration callbacks.

Member Functions

Constructors/Destructors
ManagedThread Constructor.
~ManagedThread Destructor.
Thread Creation
TryInitialize Specifies a buffer for the stack and creates a thread.
Initialize Specifies a buffer for the stack and creates a thread.
TryInitializeUsingAutoStack Automatically allocates stack and creates thread.
InitializeUsingAutoStack Automatically allocates stack and creates thread.
Starting Threads
Start Starts the processing of the thread.
Waiting for Termination and Releasing Resources
Finalize Deallocates the resources.
Join Waits for a thread to exit.
Detach Detaches thread so no longer subject to management.
IsAlive Determines whether the thread is still alive and not yet completed.
IsValid Determines whether initialized.
Getters/Setters
GetId Gets the ID that uniquely identifies the thread.
GetPriority Gets thread priority.
ChangePriority Changes the priority of the current thread.
GetIdealProcessor Gets the preferred processor number.
S GetCurrentId Gets the ID that uniquely identifies the current thread.
Stack
GetStackBufferBegin Gets the starting address of the buffer being used for the stack.
GetStackBottom Gets the address of the bottom of the stack.
GetStackBufferEnd Gets the ending address of the buffer being used for the stack.
GetStackSize Gets the size of the stack.
GetStackBufferSize Gets the size of the buffer being used for the stack.
Name
GetName Gets the name.
SetName Sets the name.
Management
S GetCurrentThread Gets the pointer to the ManagedThread corresponding to the current thread.
S FindByStackAddress Gets the pointer to the ManagedThread from the stack address.
S FindById Gets the pointer to the ManagedThread from the thread ID.
S Enumerate Enumerates the initialized ManagedThread instances.
S GetCurrentManagedCount Gets the current number of initialized ManagedThread instances.
S InitializeEnvironment Conducts initialization in order to use ManagedThread.
S IsEnabled Determines if ManagedThread can be used.

Class Hierarchy

nn::util::NonCopyable
  nn::fnd::IntrusiveLinkedList
    nn::os::ManagedThread

Revision History

2012/10/01
Added IsEnabled.
2012/04/13
Initial version.

CONFIDENTIAL