The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

QueryQueue Class Reference

QueryQueue, a queue of queries waiting to be executed. More...

#include <m_sqlv2.h>

Inheritance diagram for QueryQueue:

Inheritance graph
[legend]
Collaboration diagram for QueryQueue:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 QueryQueue ()
void push (const SQLrequest &q)
void pop ()
SQLrequestfront ()
std::pair< int, int > size ()
int totalsize ()
void PurgeModule (Module *mod)

Private Types

typedef std::deque< SQLrequestReqDeque
enum  { PRI, NOR, NON }

Private Member Functions

void DoPurgeModule (Module *mod, ReqDeque &q)

Private Attributes

ReqDeque priority
ReqDeque normal
enum QueryQueue:: { ... }  which

Detailed Description

QueryQueue, a queue of queries waiting to be executed.

This maintains two queues internally, one for 'priority' queries and one for less important ones. Each queue has new queries appended to it and ones to execute are popped off the front. This keeps them flowing round nicely and no query should ever get 'stuck' for too long. If there are queries in the priority queue they will be executed first, 'unimportant' queries will only be executed when the priority queue is empty.

We store lists of SQLrequest's here, by value as we want to avoid storing any data allocated inside the client module (in case that module is unloaded while the query is in progress).

Because we want to work on the current SQLrequest in-situ, we need a way of accessing the request we are currently processing, QueryQueue::front(), but that call needs to always return the same request until that request is removed from the queue, this is what the 'which' variable is. New queries are always added to the back of one of the two queues, but if when front() is first called then the priority queue is empty then front() will return a query from the normal queue, but if a query is then added to the priority queue then front() must continue to return the front of the *normal* queue until pop() is called.

Definition at line 497 of file m_sqlv2.h.


Member Typedef Documentation

typedef std::deque<SQLrequest> QueryQueue::ReqDeque [private]
 

Definition at line 500 of file m_sqlv2.h.


Member Enumeration Documentation

anonymous enum [private]
 

Enumerator:
PRI 
NOR 
NON 

Definition at line 504 of file m_sqlv2.h.


Constructor & Destructor Documentation

QueryQueue::QueryQueue  )  [inline]
 

Definition at line 507 of file m_sqlv2.h.


Member Function Documentation

void QueryQueue::DoPurgeModule Module mod,
ReqDeque q
[inline, private]
 

Definition at line 584 of file m_sqlv2.h.

References front(), and SQLrequest::id.

Referenced by PurgeModule().

SQLrequest& QueryQueue::front  )  [inline]
 

Definition at line 537 of file m_sqlv2.h.

References NOR, normal, PRI, priority, and which.

Referenced by SQLConn::DoConnectedPoll(), SQLConnection::DoLeadingQuery(), SQLConn::DoLeadingQuery(), DoPurgeModule(), and SQLConn::Query().

void QueryQueue::pop  )  [inline]
 

Definition at line 520 of file m_sqlv2.h.

References NON, NOR, normal, PRI, priority, and which.

Referenced by SQLConn::DoConnectedPoll(), DispatcherThread::Run(), and QueryThread::Run().

void QueryQueue::PurgeModule Module mod  )  [inline]
 

Definition at line 577 of file m_sqlv2.h.

References DoPurgeModule(), normal, and priority.

Referenced by SQLConn::OnUnloadModule().

void QueryQueue::push const SQLrequest q  )  [inline]
 

Definition at line 512 of file m_sqlv2.h.

References normal, SQLrequest::pri, and priority.

Referenced by SQLConn::Query().

std::pair<int, int> QueryQueue::size  )  [inline]
 

Definition at line 567 of file m_sqlv2.h.

References normal, and priority.

int QueryQueue::totalsize  )  [inline]
 

Definition at line 572 of file m_sqlv2.h.

References normal, and priority.

Referenced by SQLConn::DoConnectedPoll(), and SQLConn::Query().


Member Data Documentation

ReqDeque QueryQueue::normal [private]
 

Definition at line 503 of file m_sqlv2.h.

Referenced by front(), pop(), PurgeModule(), push(), size(), and totalsize().

ReqDeque QueryQueue::priority [private]
 

Definition at line 502 of file m_sqlv2.h.

Referenced by front(), pop(), PurgeModule(), push(), size(), and totalsize().

enum { ... } QueryQueue::which [private]
 

Referenced by front(), and pop().


The documentation for this class was generated from the following file: