38 while (next->
Size() < 2) {
39 this->
schedule.splice(this->
schedule.end(), this->schedule, this->schedule.begin());
41 if (next == first)
return;
60 if (this->
running.empty())
return false;
70 if (this->
running.empty())
return;
89 for (
const auto &handler :
instance.handlers) {
113 for (
auto &it : this->
running) {
146 this->
handlers[0] = std::make_unique<InitHandler>();
147 this->
handlers[1] = std::make_unique<DemandHandler>();
148 this->
handlers[2] = std::make_unique<MCFHandler<MCF1stPass>>();
149 this->
handlers[3] = std::make_unique<FlowMapper>(
false);
150 this->handlers[4] = std::make_unique<MCFHandler<MCF2ndPass>>();
151 this->handlers[5] = std::make_unique<FlowMapper>(
true);
Class for calculation jobs to be run on link graphs.
std::atomic< bool > job_completed
Is the job still running. This is accessed by multiple threads and reads may be stale.
LinkGraphID LinkGraphIndex() const
Get the ID of the underlying link graph.
bool IsJobAborted() const
Check if job has been aborted.
void SpawnThread()
Spawn a thread if possible and run the link graph job in the thread.
bool IsScheduledToBeJoined() const
Check if job is supposed to be finished.
bool IsJobCompleted() const
Check if job has actually finished.
LinkGraphSchedule()
Create a link graph schedule and initialize its handlers.
GraphList schedule
Queue for new jobs.
void SpawnNext()
Start the next job in the schedule.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
static void Clear()
Clear all link graphs and jobs from the schedule.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
~LinkGraphSchedule()
Delete a link graph schedule and its handlers.
bool IsJoinWithUnfinishedJobDue() const
Check if the next job is supposed to be finished, but has not yet completed.
static const uint SPAWN_JOIN_TICK
Tick when jobs are spawned or joined every day.
void Queue(LinkGraph *lg)
Queue a link graph for execution.
static void Run(LinkGraphJob *job)
Run all handlers for the given Job.
void JoinNext()
Join the next finished job, if available.
void Dequeue(LinkGraph *lg)
Remove a link graph from the execution queue.
std::array< std::unique_ptr< ComponentHandler >, 6 > handlers
Handlers to be run for each job.
JobList running
Currently running jobs.
void SpawnAll()
Start all threads in the running list.
A connected component of a link graph.
NodeID Size() const
Get the current size of the component.
static constexpr int SECONDS_PER_DAY
static Date date
Current date in days (day counter).
static DateFract date_fract
Fractional part of the day.
Functions related to commands.
Declaration of demand calculating link graph handler.
Declaration of flow mapper; maps paths into flows at nodes.
Types for recording game performance data.
@ PFE_GL_LINKGRAPH
Time spent waiting for link graph background jobs.
PauseModes _pause_mode
The current pause mode.
Declaration of initializing link graph handler.
void OnTick_LinkGraph()
Spawn or join a link graph job or compress a link graph if any link graph is due to do so.
void StateGameLoop_LinkGraphPauseControl()
Pause the game if in 2 TimerGameEconomy::date_fract ticks, we would do a join with the next link grap...
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,...
Declaration of link graph schedule used for cargo distribution.
Declaration of Multi-Commodity-Flow solver.
Miscellaneous command definitions.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
Basic functions/variables used all over the place.
@ LinkGraph
A game paused due to the link graph schedule lagging.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of base types and functions in a cross-platform compatible way.
static Pool::IterateWrapper< LinkGraph > Iterate(size_t from=0)
static LinkGraph * Get(auto index)
static bool CanAllocateItem(size_t n=1)
static bool IsValidID(auto index)
static T * Create(Targs &&... args)