ULimenThreadPoolSubsystem
Overview
ULimenThreadPoolSubsystem is a subsystem that manages a pool of worker threads. It provides methods to add various types of jobs (synchronous, slice-based) and ensures they are executed on separate threads. The subsystem initializes the thread pool based on developer settings and handles job distribution among available threads.
Properties
Type | Name | Access | Description |
|---|---|---|---|
| ThreadPool | Private | A map of worker threads to their corresponding runnable thread objects. |
| ThreadCount | Private | The number of worker threads in the pool. |
Functions
Return Type | Signature | Description |
|---|---|---|
| ShouldCreateSubsystem(UObject* Outer) const | Determines if the subsystem should be created based on system capabilities and developer settings. |
| Initialize(FSubsystemCollectionBase& Collection) | Initializes the thread pool with a number of threads specified in developer settings. |
| Deinitialize() | Destroys all worker threads and cleans up resources. |
| AddJob(const TFunction<void()>& Job) | Adds a synchronous job to the thread pool. |
| AddJob(const TFunction<bool(double)>& Job) | Adds a slice-based job to the thread pool. |
| AddJob(const TSharedRef & Job) | Adds an ISliceJob to the thread pool. |
| CreateThreads() | Creates worker threads based on developer settings. |
| DestroyThreads() | Destroys all worker threads and waits for their completion. |
| GetAvailableThread() const | Retrieves the worker thread with the least number of queued jobs. |
Usage & Implementation Notes
Threading Constraints: The subsystem operates on a separate thread pool, ensuring that job execution does not block the game thread.
Replication Requirements: None.
Memory Lifetime Management: Worker threads and their associated resources are managed internally by the subsystem.
Initialization Dependencies: Depends on developer settings to determine the number of threads.