Apache Mesos
event_loop.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 __EVENT_LOOP_HPP__
14 #define __EVENT_LOOP_HPP__
15 
16 #include <stout/duration.hpp>
17 #include <stout/lambda.hpp>
18 
19 namespace process {
20 
21 // The interface that must be implemented by an event management
22 // system. This is a class to cleanly isolate the interface and so
23 // that in the future we can support multiple implementations.
24 class EventLoop
25 {
26 public:
27  // Initializes the event loop.
28  static void initialize();
29 
30  // Invoke the specified function in the event loop after the
31  // specified duration.
32  // TODO(bmahler): Update this to use rvalue references.
33  static void delay(
34  const Duration& duration,
35  const lambda::function<void()>& function);
36 
37  // Returns the current time w.r.t. the event loop.
38  static double time();
39 
40  // Runs the event loop.
41  static void run();
42 
43  // Asynchronously tells the event loop to stop and then returns.
44  static void stop();
45 };
46 
47 } // namespace process {
48 
49 #endif // __EVENT_LOOP_HPP__
static void run()
static void stop()
Definition: duration.hpp:32
Definition: event_loop.hpp:24
static void delay(const Duration &duration, const lambda::function< void()> &function)
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
static void initialize()
static double time()