OpenTTD Source 20260206-master-g4d4e37dbf1
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.
void JoinNext ()
 Join the next finished job, if available.
void SpawnAll ()
 Start all threads in the running list.
void ShiftDates (TimerGameEconomy::Date 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 Dequeue (LinkGraph *lg)
 Remove a link graph from the execution queue.

Static Public Member Functions

static void Run (LinkGraphJob *job)
 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

std::array< std::unique_ptr< ComponentHandler >, 6 > handlers {}
 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

SaveLoadTable GetLinkGraphScheduleDesc ()
 Get a SaveLoad array for the link graph schedule.

Detailed Description

Definition at line 36 of file linkgraphschedule.h.

Member Typedef Documentation

◆ GraphList

typedef std::list<LinkGraph *> LinkGraphSchedule::GraphList
private

Definition at line 40 of file linkgraphschedule.h.

◆ JobList

typedef std::list<LinkGraphJob *> LinkGraphSchedule::JobList
private

Definition at line 41 of file linkgraphschedule.h.

Constructor & Destructor Documentation

◆ LinkGraphSchedule()

LinkGraphSchedule::LinkGraphSchedule ( )
private

Create a link graph schedule and initialize its handlers.

Definition at line 144 of file linkgraphschedule.cpp.

References handlers.

Referenced by GetLinkGraphScheduleDesc.

◆ ~LinkGraphSchedule()

LinkGraphSchedule::~LinkGraphSchedule ( )
private

Delete a link graph schedule and its handlers.

Definition at line 157 of file linkgraphschedule.cpp.

References Clear().

Member Function Documentation

◆ Clear()

void LinkGraphSchedule::Clear ( )
static

Clear all link graphs and jobs from the schedule.

Definition at line 121 of file linkgraphschedule.cpp.

References instance.

Referenced by ShutdownGame(), and ~LinkGraphSchedule().

◆ Dequeue()

void LinkGraphSchedule::Dequeue ( LinkGraph * lg)
inline

Remove a link graph from the execution queue.

Parameters
lgLink graph to be removed.

Definition at line 77 of file linkgraphschedule.h.

Referenced by JoinNext().

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

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

◆ JoinNext()

void LinkGraphSchedule::JoinNext ( )

Join the next finished job, if available.

Definition at line 68 of file linkgraphschedule.cpp.

References Dequeue(), LinkGraphJob::IsScheduledToBeJoined(), LinkGraphJob::LinkGraphIndex(), Queue(), and running.

◆ Queue()

void LinkGraphSchedule::Queue ( LinkGraph * lg)
inline

Queue a link graph for execution.

Parameters
lgLink graph to be queued.

Definition at line 67 of file linkgraphschedule.h.

Referenced by JoinNext().

◆ Run()

void LinkGraphSchedule::Run ( LinkGraphJob * job)
static

Run all handlers for the given Job.

Parameters
jobPointer to a link graph job.

Definition at line 87 of file linkgraphschedule.cpp.

References instance, LinkGraphJob::IsJobAborted(), and LinkGraphJob::job_completed.

Referenced by LinkGraphJob::SpawnThread().

◆ ShiftDates()

void LinkGraphSchedule::ShiftDates ( TimerGameEconomy::Date 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 135 of file linkgraphschedule.cpp.

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

References running.

◆ SpawnNext()

void LinkGraphSchedule::SpawnNext ( )

Start the next job in the schedule.

Definition at line 33 of file linkgraphschedule.cpp.

References running, schedule, LinkGraph::Size(), and LinkGraphJob::SpawnThread().

◆ GetLinkGraphScheduleDesc

SaveLoadTable GetLinkGraphScheduleDesc ( )
friend

Get a SaveLoad array for the link graph schedule.

Returns
SaveLoad array for the link graph schedule.

Definition at line 219 of file linkgraph_sl.cpp.

References LinkGraphSchedule(), REF_LINK_GRAPH, REF_LINK_GRAPH_JOB, running, schedule, and SLE_REFLIST.

Field Documentation

◆ handlers

std::array<std::unique_ptr<ComponentHandler>, 6> LinkGraphSchedule::handlers {}
protected

Handlers to be run for each job.

Definition at line 45 of file linkgraphschedule.h.

Referenced by LinkGraphSchedule().

◆ instance

LinkGraphSchedule LinkGraphSchedule::instance
static

◆ running

JobList LinkGraphSchedule::running
protected

Currently running jobs.

Definition at line 47 of file linkgraphschedule.h.

Referenced by GetLinkGraphScheduleDesc, IsJoinWithUnfinishedJobDue(), JoinNext(), SpawnAll(), and SpawnNext().

◆ schedule

GraphList LinkGraphSchedule::schedule
protected

Queue for new jobs.

Definition at line 46 of file linkgraphschedule.h.

Referenced by GetLinkGraphScheduleDesc, and SpawnNext().

◆ SPAWN_JOIN_TICK

const uint LinkGraphSchedule::SPAWN_JOIN_TICK = 21
static

Tick when jobs are spawned or joined every day.

Definition at line 51 of file linkgraphschedule.h.

Referenced by OnTick_LinkGraph(), and StateGameLoop_LinkGraphPauseControl().


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