52 void SleepFiber(
volatile int* counter,
int value);
130 for (
uint i = 0; i < contexts.
Size(); i++)
156 if (*counter != value)
168 while (*counter != value) {};
void(*) FiberFunction()
Definition fibers.h:76
FiberQueue()
constructor
Definition fibers.cc:125
static void Discard()
discard job queue
Definition fibers.cc:162
static Threading::LockFreeQueue< Job > PendingJobsQueue
async queues
Definition fibers.h:108
void(*) JobFunction(void *context)
Definition fibers.h:75
static Util::FixedArray< FiberQueue::Job > FiberContexts
Definition fibers.h:113
static void Sleep(FiberWaitContext context)
sleep fiber
Definition fibers.cc:184
static Util::FixedArray< Ptr< FiberThread > > Threads
Definition fibers.h:114
virtual ~FiberQueue()
destructor
Definition fibers.cc:132
static Util::FixedArray< Fibers::Fiber > Fibers
storage
Definition fibers.h:112
static Threading::LockFreeQueue< uint > FiberIdQueue
Definition fibers.h:109
static void Enqueue(JobFunction function, const Util::FixedArray< T * > &contexts, Threading::AtomicCounter *counter)
enqueue job
Definition fibers.h:126
static void Setup(const FiberQueueCreateInfo &info)
setup job queue
Definition fibers.cc:140
static Util::Array< FiberWaitContext > SleepingFibers
Definition fibers.h:118
static Threading::CriticalSection SleepLock
sleeping fibers
Definition fibers.h:117
static bool Dequeue(Fibers::FiberContext &fiber)
dequeue job as a fiber
Definition fibers.cc:241
static bool WakeupFiber(Fibers::FiberContext &fiber)
wake up sleeping fibers
Definition fibers.cc:194
static void Free(uint id)
free a fiber
Definition fibers.cc:175
void NewFiber()
switches the current fiber
Definition fibers.cc:87
bool HasWork()
returns true if thread has work
Definition fibers.cc:66
void SleepFiber(volatile int *counter, int value)
sleeps the current fiber and switches it for a new one
Definition fibers.cc:75
FiberThread()
constructor
Definition fibers.cc:18
__DeclareClass(FiberThread)
void EmitWakeupSignal()
called if thread needs a wakeup call before stopping
Definition fibers.cc:35
Fibers::FiberContext currentFiber
Definition fibers.h:59
void SwitchFiber()
switch back to original fiber
Definition fibers.cc:108
virtual ~FiberThread()
destructor
Definition fibers.cc:26
void DoWork()
this method runs in the thread context
Definition fibers.cc:43
Fibers::Fiber threadFiber
Definition fibers.h:60
Critical section objects are used to protect a portion of code from parallel execution.
Definition lockfreequeue.h:78
Nebula's dynamic array class.
Definition array.h:60
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
const SizeT Size() const
get number of elements
Definition fixedarray.h:532
Fiber implementation header.
Definition fiber.h:11
void Wait(Threading::AtomicCounter *counter, int value)
Definition fibers.h:154
thread_local FiberThread * currentThread
Definition fibers.cc:12
void Lock(Threading::AtomicCounter *counter, int value)
Definition fibers.h:166
void Enqueue(FiberQueue::JobFunction function, const Util::FixedArray< T * > &contexts, Threading::AtomicCounter *counter)
Definition fibers.h:145
int Exchange(int volatile *dest, int value)
interlocked exchange
Definition gccinterlocked.cc:94
volatile int AtomicCounter
Definition interlocked.h:19
Fibers::Fiber * fiber
Definition fibers.h:23
volatile int * counter
Definition fibers.h:24
Threading::AtomicCounter * counter
Definition fibers.h:83
uint id
Definition fibers.h:81
JobFunction function
Definition fibers.h:80
void * context
Definition fibers.h:82
uint numFibers
Definition fibers.h:68
uint numThreads
Definition fibers.h:67
int value
Definition fibers.h:31
Fibers::Fiber * fiber
Definition fibers.h:29
volatile int * counter
Definition fibers.h:30
unsigned int uint
Definition types.h:31