2.1. Dispatching

Dispatching Jobs

The processes of the various Pia features are handled as jobs. To perform these jobs, you must call the scheduler dispatch function nn::pia::common::Scheduler::Dispatch(). Call this function once or twice per game frame.

In an ordinary game, to reduce latency, we recommend calling the nn::pia::common::Scheduler::Dispatch() function one time both before and after game communication, for a total of two times. By calling it before and after, received data can be processed in the game and the results can be set as send data. This practice reduces latency as much as possible.

Code 2-1. Dispatching
nn::pia::common::Scheduler::CreateInstance();
nn::pia::common::Scheduler::GetInstance()->Dispatch();
Reference:

You can specify a timeout time as a parameter for the Dispatch() function, but note that there is no guarantee that processing will occur within that time.

Reference:

Some jobs are handled in an internal background thread managed by the scheduler. For that reason, one thread is consumed from the time the Scheduler instance is created until that instance is destroyed.