Ninja
Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
Pool Struct Reference

A pool for delayed edges. More...

#include <state.h>

Public Member Functions

void DelayEdge (Edge *edge)
 adds the given edge to this Pool to be delayed. More...
 
int depth () const
 
void Dump () const
 Dump the Pool and its edges (useful for debugging). More...
 
void EdgeFinished (const Edge &edge)
 informs this Pool that the given edge is no longer runnable, and should relinquish its resources back to the pool More...
 
void EdgeScheduled (const Edge &edge)
 informs this Pool that the given edge is committed to be run. More...
 
bool is_valid () const
 
const string & name () const
 
 Pool (const string &name, int depth)
 
void RetrieveReadyEdges (set< Edge * > *ready_queue)
 Pool will add zero or more edges to the ready_queue. More...
 
bool ShouldDelayEdge () const
 true if the Pool might delay this edge More...
 

Private Types

typedef set< Edge *, bool(*)(const
Edge *, const Edge *)> 
DelayedEdges
 

Static Private Member Functions

static bool WeightedEdgeCmp (const Edge *a, const Edge *b)
 

Private Attributes

int current_use_
 |current_use_| is the total of the weights of the edges which are currently scheduled in the Plan (i.e. More...
 
DelayedEdges delayed_
 
int depth_
 
string name_
 

Detailed Description

A pool for delayed edges.

Pools are scoped to a State. Edges within a State will share Pools. A Pool will keep a count of the total 'weight' of the currently scheduled edges. If a Plan attempts to schedule an Edge which would cause the total weight to exceed the depth of the Pool, the Pool will enque the Edge instead of allowing the Plan to schedule it. The Pool will relinquish queued Edges when the total scheduled weight diminishes enough (i.e. when a scheduled edge completes).

Definition at line 39 of file state.h.

Member Typedef Documentation

typedef set<Edge*,bool(*)(const Edge*, const Edge*)> Pool::DelayedEdges
private

Definition at line 78 of file state.h.

Constructor & Destructor Documentation

Pool::Pool ( const string &  name,
int  depth 
)
inlineexplicit

Definition at line 40 of file state.h.

Member Function Documentation

void Pool::DelayEdge ( Edge edge)

adds the given edge to this Pool to be delayed.

Definition at line 36 of file state.cc.

References delayed_, and depth_.

Referenced by Plan::ScheduleWork().

int Pool::depth ( ) const
inline

Definition at line 45 of file state.h.

void Pool::Dump ( ) const

Dump the Pool and its edges (useful for debugging).

Definition at line 54 of file state.cc.

References current_use_, delayed_, depth_, and name_.

void Pool::EdgeFinished ( const Edge edge)

informs this Pool that the given edge is no longer runnable, and should relinquish its resources back to the pool

Definition at line 31 of file state.cc.

References current_use_, depth_, and Edge::weight().

Referenced by Plan::ResumeDelayedJobs().

void Pool::EdgeScheduled ( const Edge edge)

informs this Pool that the given edge is committed to be run.

Pool will count this edge as using resources from this pool.

Definition at line 26 of file state.cc.

References current_use_, depth_, and Edge::weight().

Referenced by RetrieveReadyEdges(), and Plan::ScheduleWork().

bool Pool::is_valid ( ) const
inline

Definition at line 44 of file state.h.

const string& Pool::name ( ) const
inline

Definition at line 46 of file state.h.

Referenced by State::AddPool(), and Edge::Dump().

void Pool::RetrieveReadyEdges ( set< Edge * > *  ready_queue)

Pool will add zero or more edges to the ready_queue.

Definition at line 41 of file state.cc.

References current_use_, delayed_, depth_, EdgeScheduled(), and Edge::weight().

Referenced by Plan::ResumeDelayedJobs(), and Plan::ScheduleWork().

bool Pool::ShouldDelayEdge ( ) const
inline

true if the Pool might delay this edge

Definition at line 49 of file state.h.

Referenced by Plan::ScheduleWork().

bool Pool::WeightedEdgeCmp ( const Edge a,
const Edge b 
)
staticprivate

Definition at line 64 of file state.cc.

References Edge::weight().

Member Data Documentation

int Pool::current_use_
private

|current_use_| is the total of the weights of the edges which are currently scheduled in the Plan (i.e.

the edges in Plan::ready_).

Definition at line 73 of file state.h.

Referenced by Dump(), EdgeFinished(), EdgeScheduled(), and RetrieveReadyEdges().

DelayedEdges Pool::delayed_
private

Definition at line 79 of file state.h.

Referenced by DelayEdge(), Dump(), and RetrieveReadyEdges().

int Pool::depth_
private

Definition at line 74 of file state.h.

Referenced by DelayEdge(), Dump(), EdgeFinished(), EdgeScheduled(), and RetrieveReadyEdges().

string Pool::name_
private

Definition at line 69 of file state.h.

Referenced by Dump().


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