SSP21-CPP
IExecutor.h
1 /*
2  * Copyright (c) 2018, Automatak LLC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
6  * following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
9  * disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
15  * products derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef EXE4CPP_IEXECUTOR_H
26 #define EXE4CPP_IEXECUTOR_H
27 
28 #include "exe4cpp/Timer.h"
29 #include "exe4cpp/ISteadyTimeSource.h"
30 
31 /**
32 * @brief exe4cpp header-only library namespace
33 */
34 namespace exe4cpp
35 {
36 
37 /**
38  * Interface that abstracts an event loop.
39  *
40  * Events can be posted for to execute immediately or some time in the future. Events
41  * are processed in the order they are posted.
42  *
43  */
45 {
46 public:
47 
48  virtual ~IExecutor() {}
49 
50  /// @return start a new timer based on a relative time duration
51  virtual Timer start(const duration_t& duration, const action_t& action) = 0;
52 
53  /// @return start a new timer based on an absolute timestamp of the steady clock
54  virtual Timer start(const steady_time_t& expiration, const action_t& action) = 0;
55 
56  /// @return Thread-safe way to post an event to be handled asynchronously
57  virtual void post(const action_t& action) = 0;
58 };
59 
60 }
61 
62 #endif
exe4cpp header-only library namespace
Definition: AsioTimer.h:29
virtual void post(const action_t &action)=0
virtual Timer start(const duration_t &duration, const action_t &action)=0