- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
actor.hpp
Go to the documentation of this file.
1 #pragma once
2
7 #ifndef _QI_ACTOR_HPP_
8 #define _QI_ACTOR_HPP_
9
10 #include <qi/eventloop.hpp>
11 #include <qi/strand.hpp>
12
13 namespace qi
14 {
24 class QI_API Actor
25 {
26 mutable qi::Strand _strand; // The name of this members needs to be declared before using it in the signature of
27 // the following member functions. This is a C++ restriction so do not move this down.
28 public:
29 Actor() = default;
30 Actor(const Actor&) = delete; // An actor cannot be copy-able nor move-able.
31
32 explicit Actor(qi::ExecutionContext& ec)
33 : _strand(ec)
34 {}
35
36 virtual ~Actor() = default;
37
38 qi::Strand* strand() const
39 {
40 return &_strand;
41 }
42
43 template<class... Args>
44 auto stranded(Args&&... args) const
45 -> decltype(_strand.schedulerFor(std::forward<Args>(args)...)) // TODO C++14: remove this line
46 {
47 return _strand.schedulerFor(std::forward<Args>(args)...);
48 }
49
50 template<class... Args>
51 auto strandedUnwrapped(Args&&... args) const
52 -> decltype(_strand.unwrappedSchedulerFor(std::forward<Args>(args)...)) // TODO C++14: remove this line
53 {
54 return _strand.unwrappedSchedulerFor(std::forward<Args>(args)...);
55 }
56
57 template<class... Args>
58 auto async(Args&&... args) const
59 -> decltype(_strand.async(std::forward<Args>(args)...)) // TODO C++14: remove this line
60 {
61 return _strand.async(std::forward<Args>(args)...);
62 }
63
64 template<class... Args>
65 auto asyncDelay(Args&&... args) const
66 -> decltype(_strand.asyncDelay(std::forward<Args>(args)...)) // TODO C++14: remove this line
67 {
68 return _strand.asyncDelay(std::forward<Args>(args)...);
69 }
70
71 template<class... Args>
72 auto asyncAt(Args&&... args) const
73 -> decltype(_strand.asyncAt(std::forward<Args>(args)...)) // TODO C++14: remove this line
74 {
75 return _strand.asyncAt(std::forward<Args>(args)...);
76 }
77
78 void joinTasks()
79 {
80 _strand.join();
81 }
82 };
83
84 } // qi
85
86 #endif // _QI_ACTOR_HPP_
qi::asyncDelay
auto asyncDelay(F &&callback, qi::Duration delay) -> decltype(detail::asyncMaybeActor(std::forward< F >(callback), delay))
Definition: async.hpp:46
QI_API
#define QI_API
Definition: api.hpp:33
qi::Actor::stranded
auto stranded(Args &&...args) const -> decltype(_strand.schedulerFor(std::forward< Args >(args)...))
Definition: actor.hpp:44
qi::Actor::strand
qi::Strand * strand() const
Definition: actor.hpp:38
qi::Actor::asyncAt
auto asyncAt(Args &&...args) const -> decltype(_strand.asyncAt(std::forward< Args >(args)...))
Definition: actor.hpp:72
qi::ExecutionContext
Definition: executioncontext.hpp:63
qi::Actor::strandedUnwrapped
auto strandedUnwrapped(Args &&...args) const -> decltype(_strand.unwrappedSchedulerFor(std::forward< Args >(args)...))
Definition: actor.hpp:51
qi::Strand
Definition: strand.hpp:125
qi::Actor::async
auto async(Args &&...args) const -> decltype(_strand.async(std::forward< Args >(args)...))
Definition: actor.hpp:58
strand.hpp
qi::Actor::joinTasks
void joinTasks()
Definition: actor.hpp:78
qi::async
auto async(F &&callback) -> decltype(asyncDelay(std::forward< F >(callback), qi::Duration(0)))
Definition: async.hpp:53
eventloop.hpp
qi::asyncAt
auto asyncAt(F &&callback, qi::SteadyClockTimePoint timepoint) -> decltype(qi::getEventLoop() ->asyncAt(std::forward< F >(callback), timepoint))
Definition: async.hpp:39
qi::Actor::Actor
Actor(qi::ExecutionContext &ec)
Definition: actor.hpp:32
qi::Actor
Definition: actor.hpp:24
qi::Actor::asyncDelay
auto asyncDelay(Args &&...args) const -> decltype(_strand.asyncDelay(std::forward< Args >(args)...))
Definition: actor.hpp:65