Jobrocket
jobrocket Namespace Reference

Namespaces

 detail
 

Classes

struct  CurrentJobrocket
 
struct  Job
 
struct  JobFunction
 
struct  JobFunctionBase
 Abstract base class used to call the function regardless of arguments. More...
 
class  JobGroup
 
class  JobPool
 
class  Scheduler
 
class  Worker
 

Functions

template<typename Fn , typename... Args>
Job make_unmanaged_job (Fn function, Args &&... args)
 Makes a new job on the stack without a JobPool More...
 
void startup (int32_t num_workers, int32_t num_main_threads)
 
void shutdown ()
 
JobPoolcurrent_job_pool ()
 Gets a pointer to the currently active global JobPool More...
 
Schedulercurrent_scheduler ()
 Gets a pointer to the currently active global Scheduler More...
 
void run (Job *job)
 Takes a pre-allocated Job and schedules it to the currently active global scheduler. More...
 
void wait (const Job *job)
 
void register_main_thread ()
 
template<typename Fn , typename... Args>
Jobmake_job (Fn function, Args &&... args)
 Allocates a new job from the global pool with the job function and arguments given. More...
 
template<typename Fn , typename... Args>
void make_job_and_wait (Fn function, Args &&... args)
 

Function Documentation

◆ current_job_pool()

JobPool * jobrocket::current_job_pool ( )

Gets a pointer to the currently active global JobPool

◆ current_scheduler()

Scheduler * jobrocket::current_scheduler ( )

Gets a pointer to the currently active global Scheduler

◆ make_job()

template<typename Fn , typename... Args>
Job* jobrocket::make_job ( Fn  function,
Args &&...  args 
)

Allocates a new job from the global pool with the job function and arguments given.

◆ make_job_and_wait()

template<typename Fn , typename... Args>
void jobrocket::make_job_and_wait ( Fn  function,
Args &&...  args 
)

Allocates a new Job using the current global pool, schedules it and then makes the current thread wait until the jobs completion. This is analogous to calling:

auto job = jobrocket::make_job(example_job_function);

◆ make_unmanaged_job()

template<typename Fn , typename... Args>
Job jobrocket::make_unmanaged_job ( Fn  function,
Args &&...  args 
)

Makes a new job on the stack without a JobPool

◆ register_main_thread()

void jobrocket::register_main_thread ( )

◆ run()

void jobrocket::run ( Job job)

Takes a pre-allocated Job and schedules it to the currently active global scheduler.

◆ shutdown()

void jobrocket::shutdown ( )

Shuts down the global scheduler by waiting until all workers have completed the current job. All jobs sitting in worker queues are discarded

◆ startup()

void jobrocket::startup ( int32_t  num_workers = Scheduler::auto_thread_count,
int32_t  num_main_threads = Scheduler::auto_thread_count 
)

Starts up the global Scheduler and JobPool. If no value is specified for num_workers the scheduler decides how workers to create based off the current hardware - in most circumstances this is the most appropriate value.

◆ wait()

void jobrocket::wait ( const Job job)

Takes a pre-allocated and pre-scheduled Job and waits until it has completed. While waiting, the current thread will attempt to assist with completing scheduled jobs rather than going to sleep or busy waiting