OpenTTD
Public Member Functions | Static Public Member Functions | Static Public Attributes | 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 ShiftDates (int interval)
 Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of days given.
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 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.
static LinkGraphSchedule instance
 Static instance of LinkGraphSchedule.

Protected Attributes

ComponentHandlerhandlers [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 SaveLoadGetLinkGraphScheduleDesc ()
 Get a SaveLoad array for the link graph schedule.

Detailed Description

Definition at line 38 of file linkgraphschedule.h.

Member Function Documentation

void LinkGraphSchedule::Queue ( LinkGraph lg)
inline
void LinkGraphSchedule::Run ( void *  j)
static

Run all handlers for the given Job.

This method is tailored to ThreadObject::New.

Parameters
jPointer to a link graph job.

Definition at line 75 of file linkgraphschedule.cpp.

References handlers, instance, lengthof, and ComponentHandler::Run().

Referenced by LinkGraphJob::SpawnThread().

void LinkGraphSchedule::ShiftDates ( int  interval)

Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of days given.

Parameters
intervalNumber of days to be added or subtracted.

Definition at line 111 of file linkgraphschedule.cpp.

References LinkGraph::ShiftDates(), and LinkGraphJob::ShiftJoinDate().

Referenced by ClickChangeDateCheat(), and SetStartingYear().

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 87 of file linkgraphschedule.cpp.

References running.

Referenced by AfterLoadLinkGraphs().

void LinkGraphSchedule::Unqueue ( LinkGraph lg)
inline

Remove a link graph from the execution queue.

Parameters
lgLink graph to be removed.

Definition at line 78 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 96 of file linkgraph_sl.cpp.

Field Documentation

LinkGraphSchedule LinkGraphSchedule::instance
static

Static instance of LinkGraphSchedule.

Note: This instance is created on task start. Lazy creation on first usage results in a data race between the CDist threads.

Definition at line 54 of file linkgraphschedule.h.

Referenced by AfterLoadLinkGraphs(), Clear(), ClickChangeDateCheat(), IncreaseStats(), Load_LGRS(), Ptrs_LGRS(), Run(), Save_LGRS(), SetStartingYear(), and Station::~Station().


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