libapt-pkg-dev  v0.9.7.5ubuntu5.4
Debian+Ubuntu APT Package Management
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pkgAcquire::Queue Class Reference

A single download queue in a pkgAcquire object. More...

#include <acquire.h>

Collaboration diagram for pkgAcquire::Queue:

Classes

struct  QItem
 A single item placed in this queue. More...
 

Public Member Functions

 Queue (std::string Name, pkgAcquire *Owner)
 Create a new Queue. More...
 
virtual ~Queue ()
 Shut down all the worker processes associated with this queue and empty the queue. More...
 
void Bump ()
 Check for items that could be enqueued. More...
 
bool Cycle ()
 Send idle items to the worker process. More...
 
bool Dequeue (Item *Owner)
 Remove all fetch requests for the given item from this queue. More...
 
bool Enqueue (ItemDesc &Item)
 Insert the given fetch request into this queue. More...
 
QItemFindItem (std::string URI, pkgAcquire::Worker *Owner)
 Locate an item in this queue. More...
 
bool ItemDone (QItem *Itm)
 Remove the given item from this queue and set its state to pkgAcquire::Item::StatDone. More...
 
bool ItemStart (QItem *Itm, unsigned long long Size)
 Presumably this should start downloading an item? More...
 
bool Shutdown (bool Final)
 Shut down the worker process associated with this queue. More...
 
bool Startup ()
 Start the worker process associated with this queue. More...
 

Protected Attributes

QItemItems
 The head of the list of items contained in this queue. More...
 
unsigned long MaxPipeDepth
 The maximum number of entries that this queue will attempt to download at once. More...
 
std::string Name
 The name of this queue. More...
 
pkgAcquireOwner
 the download scheduler with which this queue is associated. More...
 
signed long PipeDepth
 The number of entries in this queue that are currently being downloaded. More...
 
pkgAcquire::WorkerWorkers
 The head of the list of workers associated with this queue. More...
 

Private Attributes

void * d
 dpointer placeholder (for later in case we need it) More...
 
QueueNext
 The next queue in the pkgAcquire object's list of queues. More...
 

Friends

class pkgAcquire
 
class pkgAcquire::UriIterator
 
class pkgAcquire::Worker
 

Detailed Description

A single download queue in a pkgAcquire object.

    {{{
Todo:
Why so many protected values?

Constructor & Destructor Documentation

pkgAcquire::Queue::Queue ( std::string  Name,
pkgAcquire Owner 
)

Create a new Queue.

Parameters
NameThe name of the new queue.
OwnerThe download process that owns the new queue.
virtual pkgAcquire::Queue::~Queue ( )
virtual

Shut down all the worker processes associated with this queue and empty the queue.

Member Function Documentation

void pkgAcquire::Queue::Bump ( )

Check for items that could be enqueued.

Call this after an item placed in multiple queues has gone from the pkgAcquire::Item::StatFetching state to the pkgAcquire::Item::StatIdle state, to possibly refill an empty queue. This is an alias for Cycle().

Todo:
Why both this and Cycle()? Are they expected to be different someday?
bool pkgAcquire::Queue::Cycle ( )

Send idle items to the worker process.

Fills up the pipeline by inserting idle items into the worker's queue.

bool pkgAcquire::Queue::Dequeue ( Item Owner)

Remove all fetch requests for the given item from this queue.

Returns
true if at least one request was removed from the queue.
bool pkgAcquire::Queue::Enqueue ( ItemDesc Item)

Insert the given fetch request into this queue.

Returns
true if the queuing was successful. May return false if the Item is already in the queue
QItem* pkgAcquire::Queue::FindItem ( std::string  URI,
pkgAcquire::Worker Owner 
)

Locate an item in this queue.

Parameters
URIA URI to match against.
OwnerA pkgAcquire::Worker to match against.
Returns
the first item in the queue whose URI is URI and that is being downloaded by Owner.
bool pkgAcquire::Queue::ItemDone ( QItem Itm)

Remove the given item from this queue and set its state to pkgAcquire::Item::StatDone.

If this is the only queue containing the item, the item is also removed from the main queue by calling pkgAcquire::Dequeue.

Parameters
ItmThe item to remove.
Returns
true if no errors are encountered.
bool pkgAcquire::Queue::ItemStart ( QItem Itm,
unsigned long long  Size 
)

Presumably this should start downloading an item?

Todo:
Unimplemented. Implement it or remove?
bool pkgAcquire::Queue::Shutdown ( bool  Final)

Shut down the worker process associated with this queue.

Parameters
FinalIf true, then the process is stopped unconditionally. Otherwise, it is only stopped if it does not need cleanup as indicated by the pkgAcqMethod::NeedsCleanup member of its configuration.
Returns
true.
bool pkgAcquire::Queue::Startup ( )

Start the worker process associated with this queue.

If a worker process is already associated with this queue, this is equivalent to calling Cycle().

Returns
true if the startup was successful.

Friends And Related Function Documentation

friend class pkgAcquire
friend
friend class pkgAcquire::UriIterator
friend
friend class pkgAcquire::Worker
friend

Member Data Documentation

void* pkgAcquire::Queue::d
private

dpointer placeholder (for later in case we need it)

QItem* pkgAcquire::Queue::Items
protected

The head of the list of items contained in this queue.

Todo:
why a by-hand list instead of an STL structure?

Referenced by pkgAcquire::UriIterator::operator++(), and pkgAcquire::UriIterator::UriIterator().

unsigned long pkgAcquire::Queue::MaxPipeDepth
protected

The maximum number of entries that this queue will attempt to download at once.

std::string pkgAcquire::Queue::Name
protected

The name of this queue.

Queue* pkgAcquire::Queue::Next
private

The next queue in the pkgAcquire object's list of queues.

Referenced by pkgAcquire::UriIterator::operator++(), and pkgAcquire::UriIterator::UriIterator().

pkgAcquire* pkgAcquire::Queue::Owner
protected

the download scheduler with which this queue is associated.

signed long pkgAcquire::Queue::PipeDepth
protected

The number of entries in this queue that are currently being downloaded.

pkgAcquire::Worker* pkgAcquire::Queue::Workers
protected

The head of the list of workers associated with this queue.

Todo:
This is plural because support exists in Queue for multiple workers. However, it does not appear that there is any way to actually associate more than one worker with a queue.
Todo:
Why not just use a std::set?

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