File: CombinedExecutionContext.cpp

package info (click to toggle)
freespace2 24.0.2%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 43,188 kB
  • sloc: cpp: 583,107; ansic: 21,729; python: 1,174; sh: 464; makefile: 248; xml: 181
file content (34 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "CombinedExecutionContext.h"

namespace executor {
CombinedExecutionContext::CombinedExecutionContext(SCP_vector<std::shared_ptr<IExecutionContext>> contexts)
	: m_contexts(std::move(contexts))
{
}
IExecutionContext::State CombinedExecutionContext::determineContextState() const
{
	bool suspended_context = false;
	bool invalid_context = false;
	for (const auto& context : m_contexts) {
		const auto state = context->determineContextState();

		if (state == IExecutionContext::State::Suspended) {
			suspended_context = true;
		} else if (state == IExecutionContext::State::Invalid) {
			invalid_context = true;
		}
	}

	// If there is an invalid context then the combined state is invalid
	// If there is not but there is a suspended one, then the state is suspended
	if (invalid_context) {
		return IExecutionContext::State::Invalid;
	} else if (suspended_context) {
		return IExecutionContext::State::Suspended;
	} else {
		return IExecutionContext::State::Valid;
	}
}
CombinedExecutionContext::~CombinedExecutionContext() = default;

} // namespace executor