Unigine::CPUShaderCallable Class
Header: | #include <UnigineThread.h> |
CPUShaderCallable is a template class that provides a simplified way to execute custom multithreaded logic using the CPUShader class.
Typically, to use a CPUShader, you need to inherit from the base CPUShader class and manually implement the process() method. However, CPUShaderCallable allows you to pass in the processing logic and optional cleanup logic directly as function objects without writing a custom class or managing inheritance.
It also supports an internal shared state that is accessible from all threads and can be cleaned up automatically after execution.
Template Parameters:
- State - user-defined type that stores shared state between threads.
- Process - function called per thread.
Signature: void(int thread_num, int num_threads) - Destroy - optional function called once after all threads are finished.
Signature: void(State state)
CPUShaderCallable Class
Members
CPUShaderCallable ( Process func_process_, Destroy func_destroy_ ) #
Creates a new shader task with execution and destruction logic.Arguments
- Process func_process_ - Function executed on each thread.
- Destroy func_destroy_ - Function executed once after all threads are done.
void process ( int thread_num, int num_threads ) #
Overridden from CPUShader. Called once per thread during execution. Invokes the provided processing function.Arguments
- int thread_num - Index of the current thread.
- int num_threads - Total number of threads assigned to this task.
The information on this page is valid for UNIGINE 2.20 SDK.
Last update:
2025-07-10
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)