AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
Executor.h
1
6#pragma once
7#if !defined(AWS_EXECUTOR_H)
8#define AWS_EXECUTOR_H
9
10#include <aws/core/Core_EXPORTS.h>
11
12#include <functional>
13
14namespace Aws
15{
16 namespace Utils
17 {
18 namespace Threading
19 {
24 class AWS_CORE_API Executor
25 {
26 public:
27 virtual ~Executor() = default;
28
32 template<class Fn, class ... Args>
33 bool Submit(Fn&& fn, Args&& ... args)
34 {
35 std::function<void()> callable{ std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...) };
36 return SubmitToThread(std::move(callable));
37 }
38
39 /* explicit _overload_ of the template function above to avoid template bloat */
40 bool Submit(std::function<void()>&& callable)
41 {
42 return SubmitToThread(std::move(callable));
43 }
44
48 virtual void WaitUntilStopped() { return; };
49
50 protected:
54 virtual bool SubmitToThread(std::function<void()>&&) = 0;
55 };
56 } // namespace Threading
57 } // namespace Utils
58} // namespace Aws
59
60// TODO: remove on a next minor API bump from 1.11.x
61#endif // !defined(AWS_EXECUTOR_H)
62#include <aws/core/utils/threading/DefaultExecutor.h>
63#include <aws/core/utils/threading/PooledThreadExecutor.h>
bool Submit(Fn &&fn, Args &&... args)
Definition Executor.h:33
bool Submit(std::function< void()> &&callable)
Definition Executor.h:40
virtual bool SubmitToThread(std::function< void()> &&)=0
virtual void WaitUntilStopped()
Definition Executor.h:48