A network request queue.
More...
Detailed Description
A network request queue.
Clients can add requests with an ID and priority. Later, clients can pull the most immediate requests from the queue, and that request will be backed off. Finally, clients can remove requests altogether.
The client must construct IDs on its own.
This library makes use of a "clock". In the context of a network request queue, this is just a serial counter, not a timer. There is a clock tick per datagram sent out. This library relies on the client maintaining its own clock, and respects whatever the client provides as far as current and requested clock values.
Function Documentation
virtual const char* netrq::Request::getId |
( |
void |
|
) |
const throw () [pure virtual, inherited] |
virtual int netrq::Request::getMaxBytes |
( |
void |
|
) |
const throw () [pure virtual, inherited] |
virtual void netrq::Request::write |
( |
IO xdrbuf::Output * |
output |
) |
[pure virtual, inherited] |
virtual int netrq::Request::getRetryInterval |
( |
void |
|
) |
const throw () [inline, virtual, inherited] |
if non-zero, this request is asking to be resent after the specified clock interval
Definition at line 88 of file netrq.h.
netrq::Queue::~Queue |
( |
void |
|
) |
throw () [virtual, inherited] |
virtual int netrq::Queue::size |
( |
void |
|
) |
[pure virtual, inherited] |
Returns count of requests in queue.
Approximate only, since other threads may update the queue by the time the caller gets the count.
virtual eInsertResult netrq::Queue::addRequest |
( |
IN dword_t |
sendClock, |
|
|
IN smart_ptr< Request > & |
request | |
|
) |
| | [pure virtual, inherited] |
If the addRequest fails due to a collision, the return value will tell the client whether the existing request has an earlier or later clock than what was just requested.
- Parameters:
-
| sendClock | send at this clock |
virtual bool netrq::Queue::getNextRequest |
( |
IN dword_t |
clock, |
|
|
OUT smart_ptr< Request > & |
request | |
|
) |
| | [pure virtual, inherited] |
returns the next request that should be sent.
The clock value is the current packet count, not the time. So for instance, if you are using this queue to manage UDP data, increment the clock everytime you send a UDP packet.
- Parameters:
-
virtual bool netrq::Queue::containsRequest |
( |
IN const char * |
id |
) |
[pure virtual, inherited] |
does the queue already contain a request with this id?
virtual bool netrq::Queue::removeRequest |
( |
IN const char * |
id |
) |
[pure virtual, inherited] |
smart_ptr< Queue > netrq::Queue::create |
( |
void |
|
) |
[static, inherited] |
int netrq::sendMessagesFromQueue |
( |
IO xdrbuf::Output * |
output, |
|
|
IN dword_t |
clock, |
|
|
IO Queue * |
queue | |
|
) |
| | |
Given an output buffer, write as many pending requests as possible.
All sent messages are removed from the queue. Returns the number of messages sent. See the netrq library comments regarding the clock values.
- Parameters:
-
netrq::Request::~Request |
( |
void |
|
) |
throw () [virtual, inherited] |