|
BluFedora Job System v1.0.0
This is a C++ job system library for use in game engines.
|
API for a multi-threading job system. More...
#include "concurrent/job_api.hpp"#include "concurrent/job_assert.hpp"#include "concurrent/job_queue.hpp"#include "pcg_basic.h"#include <algorithm>#include <cstdio>#include <cstdlib>#include <limits>#include <new>#include <thread>#include "pcg_basic.c"Go to the source code of this file.
Classes | |
| struct | Job::TaskPtr |
| union | Job::TaskFnStorage |
| struct | Job::Task |
| union | Job::TaskMemoryBlock |
| struct | Job::TaskPool |
| struct | Job::ThreadLocalState |
| struct | Job::InitializationLock |
| struct | Job::JobSystemContext |
Namespaces | |
| namespace | Job |
| namespace | system |
| namespace | task_pool |
| namespace | task |
| namespace | worker |
| namespace | config |
Macros | |
| #define | NativePause std::this_thread::yield |
Typedefs | |
| using | Job::TaskHandle = std::uint16_t |
| using | Job::TaskHandleType = TaskHandle |
| using | Job::AtomicTaskHandleType = std::atomic< TaskHandle > |
| using | Job::WorkerIDType = WorkerID |
| using | Job::AtomicInt32 = std::atomic_int32_t |
| using | Job::Byte = unsigned char |
| using | Job::AtomicTaskPtr = std::atomic< TaskPtr > |
Variables | |
| static constexpr std::size_t | Job::k_CachelineSize = 64u |
| static constexpr std::size_t | Job::k_ExpectedTaskSize = std::max(std::size_t(128u), k_CachelineSize) |
| static constexpr QueueType | Job::k_InvalidQueueType = QueueType(int(QueueType::WORKER) + 1) |
| static constexpr TaskHandle | Job::NullTaskHandle = std::numeric_limits<TaskHandle>::max() |
| static Job::JobSystemContext * | g_JobSystem = nullptr |
| static thread_local Job::ThreadLocalState * | g_CurrentWorker = nullptr |
API for a multi-threading job system.
References: [https://blog.molecular-matters.com/2015/08/24/job-system-2-0-lock-free-work-stealing-part-1-basics/] [https://manu343726.github.io/2017-03-13-lock-free-job-stealing-task-system-with-modern-c/] [https://github.com/cdwfs/cds_job/blob/master/cds_job.h] [https://github.com/cyshi/logbook/blob/master/src/common/work_stealing_queue.h] [https://fabiensanglard.net/doom3_bfg/threading.php] [https://gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine]
Definition in file job_system.cpp.
| union Job::TaskMemoryBlock |
Definition at line 167 of file job_system.cpp.
| Class Members | ||
|---|---|---|
| TaskMemoryBlock * | next | |
| unsigned char | storage[sizeof(Task)] | |
| struct Job::TaskPool |
Definition at line 174 of file job_system.cpp.
| Class Members | ||
|---|---|---|
| TaskMemoryBlock * | memory | |
| TaskMemoryBlock * | freelist | |
| struct Job::ThreadLocalState |
Definition at line 180 of file job_system.cpp.
| Class Members | ||
|---|---|---|
| SPMCDeque< TaskPtr > | normal_queue | |
| SPMCDeque< TaskPtr > | worker_queue | |
| TaskPool | task_allocator | |
| TaskHandle * | allocated_tasks | |
| TaskHandleType | num_allocated_tasks | |
| ThreadLocalState * | last_stolen_worker | |
| pcg_state_setseq_64 | rng_state | |
| thread | thread_id | |
| struct Job::InitializationLock |
Definition at line 192 of file job_system.cpp.
| Class Members | ||
|---|---|---|
| mutex | init_mutex | |
| condition_variable | init_cv | |
| atomic_uint32_t | num_workers_ready | |
| struct Job::JobSystemContext |
Definition at line 199 of file job_system.cpp.
| Class Members | ||
|---|---|---|
| ThreadLocalState * | workers | |
| uint32_t | num_workers | |
| uint32_t | num_owned_workers | |
| atomic_uint32_t | num_user_threads_setup | |
| uint32_t | num_tasks_per_worker | |
| InitializationLock | init_lock | |
| const char * | sys_arch_str | |
| size_t | system_alloc_size | |
| size_t | system_alloc_alignment | |
| bool | needs_delete | |
| atomic_bool | is_running | |
| LockedQueue< TaskPtr > | main_queue | |
| mutex | worker_sleep_mutex | |
| condition_variable | worker_sleep_cv | |
| atomic_uint32_t | num_available_jobs | |
| #define NativePause std::this_thread::yield |
Definition at line 1195 of file job_system.cpp.
|
static |
Definition at line 226 of file job_system.cpp.
Referenced by Job::CurrentWorker(), Job::Initialize(), Job::detail::mainQueueTryRunTask(), Job::NumWorkers(), Job::ProcessorArchitectureName(), Job::SetupUserThread(), Job::Shutdown(), Job::TaskMake(), and Job::TaskSubmit().
|
static |
Definition at line 227 of file job_system.cpp.
Referenced by Job::CurrentWorker(), Job::Initialize(), Job::IsMainThread(), and Job::Shutdown().