Player12
An open source football management simulator
Loading...
Searching...
No Matches
MatchScheduler Class Reference

Simulates a batch of independent matches in parallel. More...

#include <match_scheduler.h>

Public Member Functions

 MatchScheduler (unsigned thread_count=ThreadPool::defaultThreadCount())
 
void setThreadCount (unsigned thread_count)
 
unsigned getThreadCount () const
 
std::vector< MatchSimulationResult > run (const std::vector< MatchSimulationInput > &inputs, const StatsConfig &config)
 
void resetProgress ()
 
SimulationProgress getProgress () const
 

Private Attributes

unsigned threads = 1
 
std::unique_ptr< ThreadPool > pool
 
std::atomic< uint32_t > completed {0}
 
std::atomic< uint32_t > total {0}
 

Detailed Description

Simulates a batch of independent matches in parallel.

Results come back in input order and each match is fully determined by its input, so a batch gives identical results for any thread count.

Constructor & Destructor Documentation

◆ MatchScheduler()

MatchScheduler::MatchScheduler ( unsigned  thread_count = ThreadPool::defaultThreadCount())
explicit

Member Function Documentation

◆ getProgress()

SimulationProgress MatchScheduler::getProgress ( ) const
inline

Safe to call from any thread while a batch runs.

◆ getThreadCount()

unsigned MatchScheduler::getThreadCount ( ) const
inline

◆ resetProgress()

void MatchScheduler::resetProgress ( )
inline

Starts counting afresh (e.g. at the start of a day).

◆ run()

std::vector< MatchSimulationResult > MatchScheduler::run ( const std::vector< MatchSimulationInput > &  inputs,
const StatsConfig &  config 
)

Simulates every input; result i belongs to inputs[i].

◆ setThreadCount()

void MatchScheduler::setThreadCount ( unsigned  thread_count)

Threads per batch including the caller; 1 simulates on the caller.

Member Data Documentation

◆ completed

std::atomic<uint32_t> MatchScheduler::completed {0}
private

◆ pool

std::unique_ptr<ThreadPool> MatchScheduler::pool
private

◆ threads

unsigned MatchScheduler::threads = 1
private

◆ total

std::atomic<uint32_t> MatchScheduler::total {0}
private

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