12 #include "../stdafx.h" 19 #include "../safeguards.h" 36 while (next->
Size() < 2) {
39 if (next == first)
return;
57 if (this->
running.empty())
return;
89 for (JobList::iterator i = this->
running.begin(); i != this->
running.end(); ++i) {
114 FOR_ALL_LINK_GRAPHS(lg) lg->
ShiftDates(interval);
154 LinkGraphSchedule::instance.
JoinNext();
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void Queue(LinkGraph *lg)
Queue a link graph for execution.
Declaration of initializing link graph handler.
static Titem * Get(size_t index)
Returns Titem with given index.
void SpawnAll()
Start all threads in the running list.
void Unqueue(LinkGraph *lg)
Remove a link graph from the execution queue.
Link graph handler for MCF.
~LinkGraphSchedule()
Delete a link graph schedule and its handlers.
Tindex index
Index of this pool item.
virtual void Run(LinkGraphJob &job) const =0
Run the handler.
void ShiftDates(int interval)
Shift all dates by given interval.
void SpawnNext()
Start the next job in the schedule.
Declaration of Multi-Commodity-Flow solver.
void ShiftJoinDate(int interval)
Change the join date on date cheating.
void OnTick_LinkGraph()
Spawn or join a link graph job or compress a link graph if any link graph is due to do so...
Map the path trees generated by the MCF solver into flows.
void JoinNext()
Join the next finished job, if available.
A connected component of a link graph.
void ShiftDates(int interval)
Shift all dates (join dates and edge annotations) of link graphs and link graph jobs by the number of...
Declaration of flow mapper; maps paths into flows at nodes.
uint Size() const
Get the current size of the component.
DateFract _date_fract
Fractional part of the day.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
uint16 recalc_interval
time (in days) between subsequent checks for link graphs to be calculated.
Declaration of demand calculating link graph handler.
Declaration of link graph schedule used for cargo distribution.
static void Run(void *j)
Run all handlers for the given Job.
#define lengthof(x)
Return the length of an fixed size array.
void SpawnThread()
Spawn a thread if possible and run the link graph job in the thread.
Stateless, thread safe initialization hander.
bool IsFinished() const
Check if job is supposed to be finished.
ComponentHandler * handlers[6]
Handlers to be run for each job.
GraphList schedule
Queue for new jobs.
Stateless, thread safe demand hander.
static void Clear()
Clear all link graphs and jobs from the schedule.
LinkGraphSchedule()
Create a link graph schedule and initialize its handlers.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
LinkGraphID LinkGraphIndex() const
Get the ID of the underlying link graph.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
int32 Date
The type to store our dates in.
static const uint SPAWN_JOIN_TICK
Tick when jobs are spawned or joined every day.
JobList running
Currently running jobs.
Date _date
Current date in days (day counter)
LinkGraphSettings linkgraph
settings for link graph calculations
Class for calculation jobs to be run on link graphs.