nn::nex::Scheduler::Dispatch Member Function

Syntax

qUnsignedInt Dispatch(
     qUnsignedInt32 uiDispatchTimeout,
     qUnsignedInt32 uiFlags = 0
);

Parameters

Name Description
in uiDispatchTimeout Specifies the timeout in milliseconds.
in uiFlags Specifies the job execution method in a bit flag format. (Default is no flag.) For more information about the job execution method, see DispatchFlag.

Return Values

The number of remaining jobs that have not been executed. Continually returns a value of 1 or higher. If the return value is getting larger, this means the timeout for processing is not long enough.

Description

Executes registered jobs with the set timeout.

Executing this function executes registered jobs. However, if the specified timeout elapses, this function halts job execution and returns control to the game. Jobs that did not execute will be executed the next time Dispatch is called.

Make sure to call this function periodically. In order to keep latency (communication delay) to a minimum, we recommend that you configure a game loop according to the following sequence.

・Execute the DispatchAll or Dispatch function (for receiving)
・The application handles the received data. If you are using duplicated objects, refresh all duplicated object duplicas (apply the received data).
・Change the game state (physics calculations, AI, and so on).
・Set the data to send. If you are using duplicated objects, update all duplication masters (prepare to send data).
・Execute the DispatchAll or Dispatch function (for sending)
・The application performs rendering and other operations.

Careful attention is required when executing a process (such as loading a file while the screen display is off) that performs extreme blocking in the main thread. If execution of the main loop is delayed or job execution is not carried out, it will adversely affect the sending and receiving of messages. A determination that this is due to a timeout may be made as a result.

Also, if the timeout specified to this function is too short, the number of jobs that continue to be registered will become larger than the number of jobs that can be executed. At this time, job execution will not advance no matter how much time elapses, and the system may fall into the stated described above. Adjust the timeout period and traffic volume to meet application specifications.

The timeout is not an accurate numeric value. Note that there is a possibility of going over the time specified depending on the number of jobs, their content, and their timing. It is possible to go substantially over the time specified because of any asynchronous processes that are running, such as the ConnectivityManager::StartNATSession function.

This function (as well as the DispatchAll) cannot be called by two threads at the same time.

See Also

Scheduler::DispatchFlag

Revision History

2011/07/16
Added a link to Scheduler::DispatchFlag.
2011/05/09
Added mention that this function cannot be called from two threads at the same time.
2011/01/27
Initial version.

CONFIDENTIAL