nlib
|
This thread pool is suitable for deploying fine grain tasks. More...
#include "nn/nlib/threading/ThreadPool.h"
Inherits nn::nlib::threading::detail::LockFreeThreadPoolBase.
Public Types | |
typedef void *(* | Func) (void **args, size_t n) |
Type for functions that can be deployed to the thread pool. More... | |
typedef void(* | Callback) (void *result) |
Type for callback functions called when a task ends. More... | |
Public Member Functions | |
LockFreeThreadPool () noexcept | |
Instantiates the object with default parameters (default constructor). Must be initialized with Init . | |
~LockFreeThreadPool () noexcept | |
Destructor. Joins all threads started internally. | |
errno_t | Init (size_t work_queue_size, size_t thread_count, const ThreadSettings &settings) noexcept |
Starts a thread and initializes the thread pool. More... | |
errno_t | SubmitVarArgs (Func func, Callback callback, size_t n,...) noexcept |
A task is deployed to the thread pool by specifying the number of arguments of the function. More... | |
errno_t | Submit (Func func, Callback callback) |
A task is deployed to the thread pool without specifying the arguments of the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0) |
A task is deployed to the thread pool by specifying one argument to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2, void *arg3) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
errno_t | Submit (Func func, Callback callback, void *arg0, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7, void *arg8, void *arg9) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs() . More... | |
size_t | GetThreadCount () |
Returns the number of threads held in the thread pool. | |
This thread pool is suitable for deploying fine grain tasks.
N | The maximum number of arguments that a function deployed in the thread pool can accept. |
nlib_sleep()
or nlib_yield()
. Definition at line 127 of file ThreadPool.h.
nn::nlib::threading::LockFreeThreadPool< N >::Callback |
Type for callback functions called when a task ends.
[in] | result | Return value of Func . |
Definition at line 131 of file ThreadPool.h.
nn::nlib::threading::LockFreeThreadPool< N >::Func |
Type for functions that can be deployed to the thread pool.
[in] | args | Pointer to a void* type pointer array. |
[in] | n | The number of void* type pointers stored in args . |
n
matches the template argument N
. Definition at line 130 of file ThreadPool.h.
|
noexcept |
Starts a thread and initializes the thread pool.
[in] | work_queue_size | The size of a queue to store deployed tasks. |
[in] | thread_count | The number of threads to start. |
[in] | settings | Settings for threads to start. |
0 | Success. |
EINVAL | Indicates that thread_count is 0 or greater than 65535. |
ENOMEM | memory allocation failed. |
EALREADY | Already initialized. |
Failed | to create a thread for other reasons. |
Definition at line 357 of file ThreadPool.h.
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback | ||
) |
A task is deployed to the thread pool without specifying the arguments of the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0 | ||
) |
A task is deployed to the thread pool by specifying one argument to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2, | ||
void * | arg3 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
[in] | arg3 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2, | ||
void * | arg3, | ||
void * | arg4 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
[in] | arg3 | Argument to a function run in the thread pool. |
[in] | arg4 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2, | ||
void * | arg3, | ||
void * | arg4, | ||
void * | arg5 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
[in] | arg3 | Argument to a function run in the thread pool. |
[in] | arg4 | Argument to a function run in the thread pool. |
[in] | arg5 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2, | ||
void * | arg3, | ||
void * | arg4, | ||
void * | arg5, | ||
void * | arg6 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
[in] | arg3 | Argument to a function run in the thread pool. |
[in] | arg4 | Argument to a function run in the thread pool. |
[in] | arg5 | Argument to a function run in the thread pool. |
[in] | arg6 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2, | ||
void * | arg3, | ||
void * | arg4, | ||
void * | arg5, | ||
void * | arg6, | ||
void * | arg7 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
[in] | arg3 | Argument to a function run in the thread pool. |
[in] | arg4 | Argument to a function run in the thread pool. |
[in] | arg5 | Argument to a function run in the thread pool. |
[in] | arg6 | Argument to a function run in the thread pool. |
[in] | arg7 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2, | ||
void * | arg3, | ||
void * | arg4, | ||
void * | arg5, | ||
void * | arg6, | ||
void * | arg7, | ||
void * | arg8 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
[in] | arg3 | Argument to a function run in the thread pool. |
[in] | arg4 | Argument to a function run in the thread pool. |
[in] | arg5 | Argument to a function run in the thread pool. |
[in] | arg6 | Argument to a function run in the thread pool. |
[in] | arg7 | Argument to a function run in the thread pool. |
[in] | arg8 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
nn::nlib::threading::LockFreeThreadPool< N >::Submit | ( | Func | func, |
Callback | callback, | ||
void * | arg0, | ||
void * | arg1, | ||
void * | arg2, | ||
void * | arg3, | ||
void * | arg4, | ||
void * | arg5, | ||
void * | arg6, | ||
void * | arg7, | ||
void * | arg8, | ||
void * | arg9 | ||
) |
A task is deployed to the thread pool by specifying two arguments to the function. For more information, see SubmitVarArgs()
.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | arg0 | Argument to a function run in the thread pool. |
[in] | arg1 | Argument to a function run in the thread pool. |
[in] | arg2 | Argument to a function run in the thread pool. |
[in] | arg3 | Argument to a function run in the thread pool. |
[in] | arg4 | Argument to a function run in the thread pool. |
[in] | arg5 | Argument to a function run in the thread pool. |
[in] | arg6 | Argument to a function run in the thread pool. |
[in] | arg7 | Argument to a function run in the thread pool. |
[in] | arg8 | Argument to a function run in the thread pool. |
[in] | arg9 | Argument to a function run in the thread pool. |
0 | Success. |
EAGAIN | The queue is full. |
|
noexcept |
A task is deployed to the thread pool by specifying the number of arguments of the function.
[in] | func | Function to run in the thread pool. |
[in] | callback | Callback function that takes the return value of func as its argument. |
[in] | n | The number of arguments passed to the subsequent func . |
0 | Success. |
EINVAL | Indicates that n is too large. |
EAGAIN | The queue is full. |
Submit()
function. NULL
can be set for func
and callback
. If NULL
is set only for func
, NULL
is passed to the callback function. Definition at line 371 of file ThreadPool.h.
© 2012-2017 Nintendo Co., Ltd. All rights reserved.