BluFedora Job System v1.0.0
This is a C++ job system library for use in game engines.
job_system.cpp File Reference
#include "concurrent/job_api.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
 
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< job::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 TaskHandle job::NullTaskHandle = std::numeric_limits<TaskHandle>::max()
 
static job::JobSystemContextg_JobSystem = nullptr
 
static thread_local job::ThreadLocalStateg_CurrentWorker = nullptr
 

Class Documentation

◆ job::TaskMemoryBlock

union job::TaskMemoryBlock

Definition at line 150 of file job_system.cpp.

Class Members
TaskMemoryBlock * next
unsigned char storage[sizeof(Task)]

◆ job::TaskPool

struct job::TaskPool

Definition at line 157 of file job_system.cpp.

Class Members
TaskMemoryBlock * memory
TaskMemoryBlock * freelist

◆ job::ThreadLocalState

struct job::ThreadLocalState

Definition at line 163 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

◆ job::InitializationLock

struct job::InitializationLock

Definition at line 175 of file job_system.cpp.

Class Members
mutex init_mutex
condition_variable init_cv
atomic_uint32_t num_workers_ready

◆ job::JobSystemContext

struct job::JobSystemContext

Definition at line 182 of file job_system.cpp.

Class Members
ThreadLocalState * workers
uint32_t num_workers
atomic_uint32_t num_user_threads_setup
uint32_t num_tasks_per_worker
bool needs_delete
atomic_bool is_running
InitializationLock init_lock
const char * sys_arch_str
size_t system_alloc_size
size_t system_alloc_alignment
mutex worker_sleep_mutex
condition_variable worker_sleep_cv
atomic_size_t num_available_jobs

Macro Definition Documentation

◆ NativePause

#define NativePause   std::this_thread::yield

Definition at line 1048 of file job_system.cpp.

Variable Documentation

◆ g_JobSystem

◆ g_CurrentWorker

thread_local job::ThreadLocalState* g_CurrentWorker = nullptr
static