apt  0.9.7.5ubuntu2
Classes | Public Member Functions | Protected Attributes | Friends | List of all members
pkgAcquire::Queue Class Reference

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

#include <acquire.h>

Classes

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

Public Member Functions

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

Protected Attributes

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

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

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.

References Items, MaxPipeDepth, PipeDepth, and Workers.

~Queue ( )
virtual

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

References pkgAcquire::Items, and pkgAcquire::Shutdown().

Member Function Documentation

void 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 Cycle ( )

Send idle items to the worker process.

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

References pkgAcquire::Items, pkgAcquire::Queue::QItem::Next, pkgAcquire::ItemDesc::Owner, pkgAcquire::Worker::QueueItem(), pkgAcquire::Item::StatFetching, pkgAcquire::Item::StatIdle, pkgAcquire::Queue::QItem::Worker, and pkgAcquire::Workers.

bool 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.

References pkgAcquire::Items, pkgAcquire::Queue::QItem::Next, pkgAcquire::Item::QueueCounter, and pkgAcquire::Item::StatFetching.

Referenced by pkgAcquire::Dequeue().

bool 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

References pkgAcquire::Items, pkgAcquire::Queue::QItem::Next, pkgAcquire::ItemDesc::Owner, pkgAcquire::Item::QueueCounter, pkgAcquire::Item::StatDone, and pkgAcquire::ItemDesc::URI.

Referenced by pkgAcquire::Enqueue().

pkgAcquire::Queue::QItem * 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.

References pkgAcquire::Items.

bool 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.

References pkgAcquire::Dequeue(), pkgAcquire::ItemDesc::Owner, pkgAcquire::Item::QueueCounter, pkgAcquire::Item::StatDone, and pkgAcquire::Item::StatFetching.

bool ItemStart ( QItem Itm,
unsigned long long  Size 
)

Presumably this should start downloading an item?

Todo:
Unimplemented. Implement it or remove?
bool 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.

References pkgAcquire::Worker::GetConf(), pkgAcquire::MethodConfig::NeedsCleanup, pkgAcquire::Worker::NextQueue, and pkgAcquire::Workers.

bool 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.

References pkgAcquire::MethodConfig::Pipeline, pkgAcquire::Worker::Start(), and pkgAcquire::Workers.

Referenced by pkgAcquire::Enqueue().

Member Data Documentation

QItem* 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 Queue(), and pkgAcquire::UriIterator::UriIterator().

pkgAcquire::Worker* 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?

Referenced by Queue().


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