bool ByteBufferAsyncProcessor::terminate0()

in src/cpp/RiderLink/Source/RD/src/rd_framework_cpp/src/main/wire/ByteBufferAsyncProcessor.cpp [34:68]


bool ByteBufferAsyncProcessor::terminate0(time_t timeout, StateKind state_to_set, string_view action)
{
	{
		std::lock_guard<decltype(lock)> guard(lock);
		if (state == StateKind::Initialized)
		{
			logger->debug("Can't {} \'{}\', because it hasn't been started yet", std::string(action), id);
			cleanup0();
			return true;
		}

		if (state >= state_to_set)
		{
			logger->debug("Trying to {} async processor \'{}' but it's in state {}", std::string(action), id, to_string(state));
			return true;
		}

		state = state_to_set;
	}
	cv.notify_all();

	std::future_status status = async_future.wait_for(timeout);

	bool success = true;

	if (status == std::future_status::timeout)
	{
		logger->error("Couldn't wait async thread during time: {}", to_string(timeout));
		success = false;
	}

	cleanup0();

	return success;
}