Files @ r24489:93c2688c28bb
Branch filter:

Location: cpp/openttd-patchpack/source/src/linkgraph/init.h

Jonathan G Rennison
Change: [Linkgraph] Allow job threads to be aborted early when clearing schedule (#8416)

When link graph jobs are cleared due to abandoning the game or exiting,
flag the job as aborted.
The link graph job running in a separate thread checks the aborted flag
periodically and terminates processing early if set.
This reduces the delay at game abandon or exit if a long-running job
would otherwise still be running.
/** @file init.h Declaration of initializing link graph handler. */

#ifndef INIT_H
#define INIT_H

#include "linkgraphjob_base.h"

/**
 * Stateless, thread safe initialization handler. Initializes node and edge
 * annotations.
 */
class InitHandler : public ComponentHandler {
public:

	/**
	 * Initialize the link graph job.
	 * @param job Job to be initialized.
	 */
	virtual void Run(LinkGraphJob &job) const { job.Init(); }

	/**
	 * Virtual destructor has to be defined because of virtual Run().
	 */
	virtual ~InitHandler() {}
};

#endif /* INIT_H */