Jobrocket
jobrocket::Job Struct Reference

#include <Job.hpp>

Overview

A job is a function pointer and series of arguments to the function as well as providing a link back to its thread-local allocating pool and JobGroup counter.

Public Types

enum  State { State::unknown, State::ready, State::running, State::completed }
 Represents the state of a job at any given time. More...
 

Public Member Functions

 Job ()
 
 Job (const size_t size, void *job_function, const uint32_t allocating_worker)
 
void execute ()
 Runs the jobs function. More...
 

Public Attributes

JobPoolsource_pool
 The source pool from which the job was allocated and should be free'd from. More...
 
State state
 The jobs current running state. More...
 
detail::AtomicCountergroup_counter
 Pointer to the counter belonging to a JobGroup if the job belongs to one. More...
 
uint32_t worker_alloc
 The id of the worker that the job was allocated from. More...
 
uint8_t function [64 - data_size] {}
 Buffer holding the JobFunction and associated arguments. More...
 

Static Public Attributes

static constexpr size_t data_size
 Size of all members, used to offset the function buffer. More...
 

Member Enumeration Documentation

◆ State

enum jobrocket::Job::State
strong

Represents the state of a job at any given time.

Enumerator
unknown 
ready 
running 
completed 

Constructor & Destructor Documentation

◆ Job() [1/2]

jobrocket::Job::Job ( )
inline

◆ Job() [2/2]

jobrocket::Job::Job ( const size_t  size,
void *  job_function,
const uint32_t  allocating_worker 
)
inline

Member Function Documentation

◆ execute()

void jobrocket::Job::execute ( )
inline

Runs the jobs function.

Member Data Documentation

◆ data_size

constexpr size_t jobrocket::Job::data_size
static
Initial value:
= sizeof(source_pool) + sizeof(state) +
sizeof(group_counter) + sizeof(worker_alloc)

Size of all members, used to offset the function buffer.

◆ function

uint8_t jobrocket::Job::function[64 - data_size] {}

Buffer holding the JobFunction and associated arguments.

◆ group_counter

detail::AtomicCounter* jobrocket::Job::group_counter

Pointer to the counter belonging to a JobGroup if the job belongs to one.

◆ source_pool

JobPool* jobrocket::Job::source_pool

The source pool from which the job was allocated and should be free'd from.

◆ state

State jobrocket::Job::state

The jobs current running state.

◆ worker_alloc

uint32_t jobrocket::Job::worker_alloc

The id of the worker that the job was allocated from.