36#ifndef _UTILS_SCHEDULEDQUEUE_HXX_
37#define _UTILS_SCHEDULEDQUEUE_HXX_
98 if (
bands_[i].currentToken_.trunc() >= 1)
121 if (!
bands_[i].queue_.empty())
130 DIE(
"Unexpected nonempty queue");
Class to allow convenient locking and unlocking of mutexes in a C context.
This class provides a mutex API.
Essentially a "next" pointer container.
This class implements a linked list "queue" of buffers.
void insert_locked(QMember *item, unsigned index=0)
Add an item to the back of the queue.
Result next_locked()
Get an item from the front of the queue.
size_t pending(unsigned index)
Get the number of pending items in the queue.
ScheduledQueue is a queue with multiple priorities, where each priority is a FIFO list.
~ScheduledQueue()
Destructor.
size_t pending() const
Get the number of pending items in the queue (all bands total)
OSMutex lock_
Protects insert and next operations.
void insert(QMember *item, unsigned prio)
Adds an entry to the queue.
Band * bands_
The actual priority bands.
Result next()
Get an item from the queue.
unsigned numPending_
How many queue entries are pending.
size_t pending(unsigned prio)
Get the number of pending items in the queue.
unsigned num_prio() const
unsigned numBands_
How many priority bands we have.
OSMutex * lock()
The caller must acquire this lock before using any of the _locked() functions.
Result next_locked()
Get an item from the queue.
ScheduledQueue(unsigned num_bands, const Fixed16 *strides)
Constructor.
void insert_locked(QMember *item, unsigned prio)
Adds an entry to the queue.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DIE(MSG)
Unconditionally terminates the current process with a message.
Result of pulling an item from the queue based on priority.
unsigned index
index of item pulled from queue
QMember * item
item pulled from queue
This structure contains information about one priority band.
Fixed16 currentToken_
How many tokens we have right now.
Fixed16 stride_
How many tokens we add each call.
Q queue_
Holds the queue for this priority band.