Ninja
Pool Struct Reference

A pool for delayed edges. More...

#include <state.h>

Classes

struct  WeightedEdgeCmp
 

Public Member Functions

int current_use () const
 
void DelayEdge (Edge *edge)
 adds the given edge to this Pool to be delayed.
 
int depth () const
 
void Dump () const
 Dump the Pool and its edges (useful for debugging).
 
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
 
void EdgeScheduled (const Edge &edge)
 informs this Pool that the given edge is committed to be run.
 
bool is_valid () const
 
const std::string & name () const
 
 Pool (const std::string &name, int depth)
 
void RetrieveReadyEdges (EdgePriorityQueue *ready_queue)
 Pool will add zero or more edges to the ready_queue.
 
bool ShouldDelayEdge () const
 true if the Pool might delay this edge
 

Private Types

typedef std::set< Edge *, WeightedEdgeCmpDelayedEdges
 

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.
 
DelayedEdges delayed_
 
int depth_
 
std::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 enqueue 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 40 of file state.h.

Member Typedef Documentation

◆ DelayedEdges

typedef std::set<Edge*, WeightedEdgeCmp> Pool::DelayedEdges
private

Definition at line 90 of file state.h.

Constructor & Destructor Documentation

◆ Pool()

Pool::Pool ( const std::string & name,
int depth )
inline

Definition at line 41 of file state.h.

References current_use_, delayed_, depth(), depth_, name(), and name_.

Member Function Documentation

◆ current_use()

int Pool::current_use ( ) const
inline

Definition at line 48 of file state.h.

References current_use_.

Referenced by TEST_F().

◆ DelayEdge()

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::ScheduleInitialEdges(), and Plan::ScheduleWork().

◆ depth()

int Pool::depth ( ) const
inline

Definition at line 46 of file state.h.

References depth_.

Referenced by Pool().

◆ Dump()

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

◆ EdgeFinished()

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::EdgeFinished().

◆ EdgeScheduled()

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().

◆ is_valid()

bool Pool::is_valid ( ) const
inline

Definition at line 45 of file state.h.

References depth_.

◆ name()

const std::string & Pool::name ( ) const
inline

Definition at line 47 of file state.h.

References name_.

Referenced by State::AddPool(), and Pool().

◆ RetrieveReadyEdges()

void Pool::RetrieveReadyEdges ( EdgePriorityQueue * 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::EdgeFinished(), and Plan::ScheduleWork().

◆ ShouldDelayEdge()

bool Pool::ShouldDelayEdge ( ) const
inline

true if the Pool might delay this edge

Definition at line 51 of file state.h.

References depth_.

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

Member Data Documentation

◆ current_use_

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 75 of file state.h.

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

◆ delayed_

DelayedEdges Pool::delayed_
private

Definition at line 91 of file state.h.

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

◆ depth_

int Pool::depth_
private

◆ name_

std::string Pool::name_
private

Definition at line 71 of file state.h.

Referenced by Dump(), name(), and Pool().


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