CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
IdleService.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
13
14namespace CeresEngine {
15
18 class IdleService final : public ExecutionContext::Service<IdleService> {
19 private:
23
24 public:
25 using Service::Service;
26
30 template<typename Function> void post(Function&& function) { mQueue.emplace_back(std::forward<Function>(function)); }
31
34 void poll();
35
36 private:
39 };
40
43 asio::use_service<IdleService>(context).post(std::move(token));
44 }
45
46} // namespace CeresEngine
Definition ExecutionContext.hpp:96
A context for function object execution.
Definition ExecutionContext.hpp:90
A service that allows submitting work to be ran whenever the executor is going idle.
Definition IdleService.hpp:18
void poll()
Polls the service for any work.
void post(Function &&function)
Submits a new callback to be invoked.
Definition IdleService.hpp:30
List< UniqueFunction< void()> > mQueue
A list of work to be ran by the service the next time it's executor becomes idle.
Definition IdleService.hpp:22
Definition Application.hpp:19
ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) idle(ExecutionContext &context
std::list< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > List
List is a container that supports constant time insertion and removal of elements from anywhere in th...
Definition List.hpp:21
FunctionBase< true, true, fu2::capacity_default, true, false, Signatures... > Function
An owning copyable function wrapper for arbitrary callable types.
Definition Function.hpp:54
ASIO_MOVE_ARG(CompletionToken) token)
Definition IdleService.hpp:42
FunctionBase< true, false, fu2::capacity_default, true, false, Signatures... > UniqueFunction
An owning non copyable function wrapper for arbitrary callable types.
Definition Function.hpp:59
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25