2 Copyright (c) 2018-2019 Nokia.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
17 #ifndef SHAREDDATALAYER_ENGINEIMPL_HPP_
18 #define SHAREDDATALAYER_ENGINEIMPL_HPP_
23 #include <sys/epoll.h>
24 #include "private/engine.hpp"
25 #include "private/filedescriptor.hpp"
27 namespace shareddatalayer
33 class EngineImpl: public Engine
38 explicit EngineImpl(System& system);
42 int fd() const override { return epollFD; }
44 void handleEvents() override;
46 void addMonitoredFD(int fd, unsigned int events, const EventHandler& eh) override;
48 void addMonitoredFD(FileDescriptor& fd, unsigned int events, const EventHandler& eh) override;
50 void modifyMonitoredFD(int fd, unsigned int events) override;
52 void deleteMonitoredFD(int fd) override;
54 void postCallback(const Callback& callback) override;
61 void armTimer(Timer& timer, const Timer::Duration& duration, const Timer::Callback& cb) override;
63 void disarmTimer(const Timer& timer) override;
66 TimerFD& getTimerFD();
68 EventFD& getEventFD();
70 void epollWait(int timeout);
72 void callHandler(const epoll_event& e);
76 FileDescriptor epollFD;
77 std::map<int, EventHandler> handlers;
78 std::vector<epoll_event> ebuffer;
79 std::unique_ptr<TimerFD> timerFD;
80 std::unique_ptr<EventFD> eventFD;