OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
16 #include "../framerate_type.h"
17 #include "../command_func.h"
18 #include "../network/network.h"
20 #include "../safeguards.h"
37 while (next->
Size() < 2) {
38 this->
schedule.splice(this->
schedule.end(), this->schedule, this->schedule.begin());
40 if (next == first)
return;
59 if (this->
running.empty())
return false;
69 if (this->
running.empty())
return;
112 for (JobList::iterator i = this->
running.begin(); i != this->running.end(); ++i) {
static void Clear()
Clear all link graphs and jobs from the schedule.
static Titem * Get(size_t index)
Returns Titem with given index.
void JoinNext()
Join the next finished job, if available.
A connected component of a link graph.
Stateless, thread safe demand handler.
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
static const uint SPAWN_JOIN_TICK
Tick when jobs are spawned or joined every day.
Class for calculation jobs to be run on link graphs.
DateFract _date_fract
Fractional part of the day.
JobList running
Currently running jobs.
bool _network_server
network-server is active
bool IsJobCompleted() const
Check if job has actually finished.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
Tindex index
Index of this pool item.
std::atomic< bool > job_completed
Is the job still running. This is accessed by multiple threads and reads may be stale.
@ PFE_GL_LINKGRAPH
Time spent waiting for link graph background jobs.
void AfterLoad_LinkGraphPauseControl()
Pause the game on load if we would do a join with the next link graph job, but it is still running,...
void SpawnAll()
Start all threads in the running list.
LinkGraphID LinkGraphIndex() const
Get the ID of the underlying link graph.
void OnTick_LinkGraph()
Spawn or join a link graph job or compress a link graph if any link graph is due to do so.
@ PM_UNPAUSED
A normal unpaused game.
void Queue(LinkGraph *lg)
Queue a link graph for execution.
Date _date
Current date in days (day counter)
void SpawnThread()
Spawn a thread if possible and run the link graph job in the thread.
virtual void Run(LinkGraphJob &job) const =0
Run the handler.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
@ CMD_PAUSE
pause the game
bool IsScheduledToBeJoined() const
Check if job is supposed to be finished.
int32 Date
The type to store our dates in.
uint Size() const
Get the current size of the component.
PauseMode _pause_mode
The current pause mode.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void SpawnNext()
Start the next job in the schedule.
bool _networking
are we in networking mode?
LinkGraphSchedule()
Create a link graph schedule and initialize its handlers.
LinkGraphSettings linkgraph
settings for link graph calculations
GraphList schedule
Queue for new jobs.
Map the path trees generated by the MCF solver into flows.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
uint16 recalc_interval
time (in days) between subsequent checks for link graphs to be calculated.
bool IsJobAborted() const
Check if job has been aborted.
bool IsJoinWithUnfinishedJobDue() const
Check if the next job is supposed to be finished, but has not yet completed.
Link graph handler for MCF.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
@ PM_PAUSED_LINK_GRAPH
A game paused due to the link graph schedule lagging.
#define lengthof(x)
Return the length of an fixed size array.
static void Run(LinkGraphJob *job)
Run all handlers for the given Job.
ComponentHandler * handlers[6]
Handlers to be run for each job.
void Unqueue(LinkGraph *lg)
Remove a link graph from the execution queue.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
~LinkGraphSchedule()
Delete a link graph schedule and its handlers.
Stateless, thread safe initialization handler.
void StateGameLoop_LinkGraphPauseControl()
Pause the game if in 2 _date_fract ticks, we would do a join with the next link graph job,...