OpenTTD Source: LinkGraphSchedule Class Reference

OpenTTD Source 1.11.0-RC1

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.
bool | IsJoinWithUnfinishedJobDue () const
| Check if the next job is supposed to be finished, but has not yet completed. More...
void | JoinNext ()
| Join the next finished job, if available.
void | SpawnAll ()
| Start all threads in the running list. More...
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. More...
void | Queue (LinkGraph *lg)
| Queue a link graph for execution. More...
void | Unqueue (LinkGraph *lg)
| Remove a link graph from the execution queue. More...

## Static Public Member Functions
static void | Run (LinkGraphJob *job)
| Run all handlers for the given Job. More...
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. More...

## 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 friend SaveLoad * | GetLinkGraphScheduleDesc ()
| Get a SaveLoad array for the link graph schedule. More...

## Detailed Description

Definition at line 36 of file linkgraphschedule.h.

## Member Function Documentation

## ◆ IsJoinWithUnfinishedJobDue()

bool LinkGraphSchedule::IsJoinWithUnfinishedJobDue | ( |  | ) | const

Check if the next job is supposed to be finished, but has not yet completed.

Returns
  True if job should be finished by now but is still running, false if not.

Definition at line 57 of file linkgraphschedule.cpp.

References LinkGraphJob::IsJobCompleted(), LinkGraphJob::IsScheduledToBeJoined(), and running.

Referenced by StateGameLoop_LinkGraphPauseControl().

## ◆ Queue()

void LinkGraphSchedule::Queue | ( | LinkGraph * | lg | ) |
| inline

Queue a link graph for execution.

Parameters

  lg | Link graph to be queued.

Definition at line 67 of file linkgraphschedule.h.

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

Referenced by JoinNext().

## ◆ Run()

void LinkGraphSchedule::Run | ( | LinkGraphJob * | job | ) |
| static

Run all handlers for the given Job.

Parameters

  job | Pointer to a link graph job.

Definition at line 86 of file linkgraphschedule.cpp.

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

Referenced by LinkGraphJob::SpawnThread().

## ◆ ShiftDates()

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

  interval | Number of days to be added or subtracted.

Definition at line 134 of file linkgraphschedule.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Iterate(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_job_pool >::Iterate().

Referenced by ClickChangeDateCheat(), and SetStartingYear().

## ◆ SpawnAll()

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

References running.

Referenced by AfterLoadLinkGraphs().

## ◆ Unqueue()

void LinkGraphSchedule::Unqueue | ( | LinkGraph * | lg | ) |
| inline

Remove a link graph from the execution queue.

Parameters

  lg | Link graph to be removed.

Definition at line 77 of file linkgraphschedule.h.

Referenced by JoinNext().

## Friends And Related Function Documentation

## ◆ GetLinkGraphScheduleDesc

const friend SaveLoad* GetLinkGraphScheduleDesc | ( |  | ) |
| friend

Get a SaveLoad array for the link graph schedule.

Returns
  SaveLoad array for the link graph schedule.

Definition at line 99 of file linkgraph_sl.cpp.

## Field Documentation

## ◆ instance

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 52 of file linkgraphschedule.h.

Referenced by AfterLoad_LinkGraphPauseControl(), AfterLoadLinkGraphs(), Clear(), ClickChangeDateCheat(), Load_LGRS(), OnTick_LinkGraph(), Ptrs_LGRS(), Run(), Save_LGRS(), SetStartingYear(), and StateGameLoop_LinkGraphPauseControl().

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

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