Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Friends

# LinkGraphSchedule Class Reference

## Public Member Functions
void | SpawnNext ()
| Start the next job in the schedule.
void | JoinNext ()
| Join the next finished job, if available.
void | SpawnAll ()
| Start all threads in the running list.
void | Queue (LinkGraph *lg)
| Queue a link graph for execution.
void | Unqueue (LinkGraph *lg)
| Remove a link graph from the execution queue.
## Static Public Member Functions
static LinkGraphSchedule * | Instance ()
| Retrieve the link graph schedule or create it if necessary.
static void | Run (void *j)
| Run all handlers for the given Job.
static void | Clear ()
| Clear all link graphs and jobs from the schedule.
## Static Public Attributes
static const uint | SPAWN_JOIN_TICK = 21
| Tick when jobs are spawned or joined every day.
## Protected Member Functions
void | SpawnThread (LinkGraphJob *job)
| Spawn a thread if possible and run the link graph job in the thread.
void | JoinThread (LinkGraphJob *job)
| Join the calling thread with the given job's thread if threading is enabled.
## Protected Attributes
ComponentHandler * | handlers [6]
| Handlers to be run for each job.
GraphList | schedule
| Queue for new jobs.
JobList | running
| Currently running jobs.
## Private Types
typedef std::list< LinkGraph * > | GraphList
typedef std::list< LinkGraphJob * > | JobList
## Private Member Functions
| LinkGraphSchedule ()
| Create a link graph schedule and initialize its handlers.
| ~LinkGraphSchedule ()
| Delete a link graph schedule and its handlers.
## Friends
const SaveLoad * | GetLinkGraphScheduleDesc ()
| Get a SaveLoad array for the link graph schedule.

## Detailed Description

Definition at line 38 of file linkgraphschedule.h.

## Member Function Documentation

void LinkGraphSchedule::JoinThread | ( | LinkGraphJob * | job | ) | `[protected]`

Join the calling thread with the given job's thread if threading is enabled.

Parameters:

  | job | Job whose execution thread is to be joined.

Definition at line 44 of file linkgraphschedule.cpp.

References ThreadObject::Join(), and LinkGraphJob::thread.

Referenced by Clear(), and JoinNext().

void LinkGraphSchedule::Queue | ( | LinkGraph * | lg | ) | `[inline]`

Queue a link graph for execution.

Parameters:

  | lg | Link graph to be queued.

Definition at line 70 of file linkgraphschedule.h.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and schedule.

Referenced by IncreaseStats(), and JoinNext().

void LinkGraphSchedule::Run | ( | void * | j | ) | `[static]`

Run all handlers for the given Job.

This method is tailored to ThreadObject::New.

Parameters:

  | j | Pointer to a link graph job.

Definition at line 95 of file linkgraphschedule.cpp.

References handlers, Instance(), lengthof, ComponentHandler::Run(), and schedule.

Referenced by SpawnThread().

void LinkGraphSchedule::SpawnAll | ( |  | ) |

Start all threads in the running list.

This is only useful for save/load. Usually threads are started when the job is created.

Definition at line 108 of file linkgraphschedule.cpp.

References running, and SpawnThread().

Referenced by AfterLoadLinkGraphs().

void LinkGraphSchedule::SpawnThread | ( | LinkGraphJob * | job | ) | `[protected]`

Spawn a thread if possible and run the link graph job in the thread.

If that's not possible run the job right now in the current thread.

Parameters:

  | job | Job to be executed.

Definition at line 24 of file linkgraphschedule.cpp.

References ThreadObject::New(), Run(), and LinkGraphJob::thread.

Referenced by SpawnAll(), and SpawnNext().

void LinkGraphSchedule::Unqueue | ( | LinkGraph * | lg | ) | `[inline]`

Remove a link graph from the execution queue.

Parameters:

  | lg | Link graph to be removed.

Definition at line 80 of file linkgraphschedule.h.

References schedule.

Referenced by IncreaseStats(), JoinNext(), and Station::~Station().

## Friends And Related Function Documentation

const SaveLoad* GetLinkGraphScheduleDesc | ( |  | ) | `[friend]`

Get a SaveLoad array for the link graph schedule.

Returns:
  SaveLoad array for the link graph schedule.

Definition at line 94 of file linkgraph_sl.cpp.

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

- src/linkgraph/linkgraphschedule.h
- src/linkgraph/linkgraphschedule.cpp