Apache Mesos
libevent.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License
12 
13 #ifndef __LIBEVENT_HPP__
14 #define __LIBEVENT_HPP__
15 
16 #include <event2/event.h>
17 
18 #include <stout/lambda.hpp>
19 
20 namespace process {
21 
22 // Event loop.
23 extern event_base* base;
24 
25 
26 // Per thread bool pointer. We use a pointer to lazily construct the
27 // actual bool.
28 extern thread_local bool* _in_event_loop_;
29 
30 
31 #define __in_event_loop__ *(_in_event_loop_ == nullptr ? \
32  _in_event_loop_ = new bool(false) : _in_event_loop_)
33 
34 
36 {
39 };
40 
41 
43  const lambda::function<void()>& f,
44  EventLoopLogicFlow event_loop_logic_flow = ALLOW_SHORT_CIRCUIT);
45 
46 } // namespace process {
47 
48 #endif // __LIBEVENT_HPP__
Definition: libevent.hpp:38
F && f
Definition: defer.hpp:270
Definition: libevent.hpp:37
event_base * base
Future< T > run_in_event_loop(const LoopIndex loop_index, const lambda::function< Future< T >(struct ev_loop *)> &f)
Definition: libev.hpp:83
thread_local struct ev_loop * _in_event_loop_
Definition: libevent.hpp:28
Definition: executor.hpp:48
EventLoopLogicFlow
Definition: libevent.hpp:35