CTR Pia  4.11.3
Game Communication Engine
nn::pia::common::Scheduler Class Reference

Represents a job scheduler. More...

+ Inheritance diagram for nn::pia::common::Scheduler:

Public Member Functions

void Dispatch (u32 timeout=0)
 Dispatches jobs. More...
 
virtual void Trace (u64 flag) const
 Prints information that is useful for debugging. More...
 

Static Public Member Functions

static nn::Result CreateInstance (s32 backgroundThreadPriority=DEFAULT_BACKGROUND_THREAD_PRIORITY)
 Creates an instance (singleton pattern). More...
 
static void DestroyInstance ()
 Destroys the instance (singleton pattern). More...
 
static SchedulerGetInstance ()
 Gets a pointer to the Scheduler instance (singleton pattern). More...
 

Static Public Attributes

static const s32 DEFAULT_BACKGROUND_THREAD_PRIORITY = 24
 Specifies the default priority value threads used by the background scheduler.
 

Detailed Description

Represents a job scheduler.

The scheduler object is used to asynchronously execute processes defined by the Job class. This class is not thread-safe.

Revision History:

2014-09-18 Changed the specifications so that ResultAlreadyExists is returned if you call CreateInstance when an instance already exists.

2012-07-03 Changed the background scheduler priority check.

2012-06-15 The Dispatch function used to return nn::Result, but no longer returns a value.

2012-05-21 Added a feature for running jobs in a different thread. The parameters and return values of CreateInstance have been changed accordingly.

2012-04-04 Initial version.

Member Function Documentation

static nn::Result nn::pia::common::Scheduler::CreateInstance ( s32  backgroundThreadPriority = DEFAULT_BACKGROUND_THREAD_PRIORITY)
static

Creates an instance (singleton pattern).

Call this member function after calling nn::pia::common::BeginSetup, but before calling nn::pia::common::EndSetup.

Parameters
[in]backgroundThreadPrioritySpecifies the priority of the thread used by the background scheduler. Be sure to specify a priority lower than the thread used to call Pia member functions.
Returns
Returns a Result value that indicates success if the instance is created successfully. You must make sure that the implementation of this function in your application does not return any errors.
Error Return Values:

ResultAlreadyExists Indicates that an instance has already been created. Programming error. Fix your program so that this error is not returned.

ResultNotInitialized The common module has not been initialized. Programming error. Fix your program so that this error is not returned.

ResultInvalidState Indicates that the function was not called between the BeginSetup and EndSetup functions. Programming error. Fix your program so that this error is not returned.

ResultInvalidArgument Indicates an argument is invalid. Programming error. Fix your program so that this error is not returned.

static void nn::pia::common::Scheduler::DestroyInstance ( )
static

Destroys the instance (singleton pattern).

If this function is called when an instance has not been created, it does nothing and returns.

void nn::pia::common::Scheduler::Dispatch ( u32  timeout = 0)

Dispatches jobs.

Jobs are run by calling this function.

Parameters
[in]timeoutSpecifies the timeout value serving as the upper limit for job execution. The value is in milliseconds. There is, however, no guarantee that jobs will occur within the timeout period. A value of zero is interpreted as if no timeout was specified.
static Scheduler* nn::pia::common::Scheduler::GetInstance ( )
inlinestatic

Gets a pointer to the Scheduler instance (singleton pattern).

Returns
Returns a NULL pointer if the instance cannot be created.
virtual void nn::pia::common::Scheduler::Trace ( u64  flag) const
virtual

Prints information that is useful for debugging.

Parameters
[in]flagSpecifies the bitwise OR of trace flags. For more information, see the TraceFlag type.