Open Lighting Architecture: common/io/WindowsPoller.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
WindowsPoller.h
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 * WindowsPoller.h
17 * A Poller for the Windows platform
18 * Copyright (C) 2014 Lukas Erlinghagen
19 */
20
21#ifndef COMMON_IO_WINDOWSPOLLER_H_
22#define COMMON_IO_WINDOWSPOLLER_H_
23
24#include <ola/Clock.h>
25#include <ola/ExportMap.h>
26#include <ola/base/Macro.h>
27#include <ola/io/Descriptor.h>
28
29#define WIN32_LEAN_AND_MEAN
30#include <ola/win/CleanWindows.h>
31
32#include <map>
33#include <utility>
34#include <vector>
35
36#include "common/io/PollerInterface.h"
37#include "common/io/TimeoutManager.h"
38
39namespace ola {
40namespace io {
41
46 class WindowsPoller : public PollerInterface {
47 public :
53 WindowsPoller(ExportMap *export_map, Clock *clock);
54
55 ~WindowsPoller();
56
57 bool AddReadDescriptor(class ReadFileDescriptor *descriptor);
58 bool AddReadDescriptor(class ConnectedDescriptor *descriptor,
59 bool delete_on_close);
60 bool RemoveReadDescriptor(class ReadFileDescriptor *descriptor);
61 bool RemoveReadDescriptor(class ConnectedDescriptor *descriptor);
62
63 bool AddWriteDescriptor(class WriteFileDescriptor *descriptor);
64 bool RemoveWriteDescriptor(class WriteFileDescriptor *descriptor);
65
66 const TimeStamp *WakeUpTime() const { return &m_wake_up_time; }
67
68 bool Poll(TimeoutManager *timeout_manager,
69 const TimeInterval &poll_interval);
70
71 private:
72 typedef std::map<void*, class WindowsPollerDescriptor*> DescriptorMap;
73 typedef std::vector<class WindowsPollerDescriptor*> OrphanedDescriptors;
74
75 ExportMap *m_export_map;
76 CounterVariable *m_loop_iterations;
77 CounterVariable *m_loop_time;
78 Clock *m_clock;
79 TimeStamp m_wake_up_time;
80
81 DescriptorMap m_descriptor_map;
82 OrphanedDescriptors m_orphaned_descriptors;
83
84 std::pair<WindowsPollerDescriptor*, bool>
85 LookupOrCreateDescriptor(void* handle);
86 bool RemoveDescriptor(const DescriptorHandle &handle,
87 int flag,
88 bool warn_on_missing);
89
90 void HandleWakeup(class PollData* data);
91 void FinalCheckIOs(std::vector<class PollData*> data);
92
93 WindowsPoller(const WindowsPoller &) = delete;
94 const WindowsPoller &operator=(const WindowsPoller &) = delete;
95};
96} // namespace io
97} // namespace ola
98#endif // COMMON_IO_WINDOWSPOLLER_H_
ExportMap.h
Export variables on the http server.
Macro.h
Helper macros.
ola::Clock
Used to get the current time.
Definition Clock.h:230
ola::CounterVariable
Definition ExportMap.h:176
ola::ExportMap
A container for the exported variables.
Definition ExportMap.h:324
ola::TimeInterval
Definition Clock.h:126
ola::TimeStamp
Definition Clock.h:179
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::io::PollData
Definition WindowsPoller.cpp:223
ola::io::PollerInterface
The interface for the Poller classes.
Definition PollerInterface.h:70
ola::io::ReadFileDescriptor
Represents a file descriptor that supports reading data.
Definition Descriptor.h:140
ola::io::TimeoutManager
Manages timer events.
Definition TimeoutManager.h:45
ola::io::WindowsPoller::WindowsPoller
WindowsPoller(ExportMap *export_map, Clock *clock)
Create a new WindowsPoller.
Definition WindowsPoller.cpp:102
ola::io::WindowsPoller::RemoveReadDescriptor
bool RemoveReadDescriptor(class ReadFileDescriptor *descriptor)
Unregister a ReadFileDescriptor for read events.
Definition WindowsPoller.cpp:176
ola::io::WindowsPoller::AddReadDescriptor
bool AddReadDescriptor(class ReadFileDescriptor *descriptor)
Register a ReadFileDescriptor for read events.
Definition WindowsPoller.cpp:133
ola::io::WindowsPoller::AddWriteDescriptor
bool AddWriteDescriptor(class WriteFileDescriptor *descriptor)
Register a WriteFileDescriptor to receive ready-to-write events.
Definition WindowsPoller.cpp:188
ola::io::WindowsPoller::Poll
bool Poll(TimeoutManager *timeout_manager, const TimeInterval &poll_interval)
Poll the Descriptors for events and execute any callbacks.
Definition WindowsPoller.cpp:287
ola::io::WindowsPoller::RemoveWriteDescriptor
bool RemoveWriteDescriptor(class WriteFileDescriptor *descriptor)
Unregister a WriteFileDescriptor for write events.
Definition WindowsPoller.cpp:216
ola::io::WriteFileDescriptor
Represents a file descriptor that supports writing data.
Definition Descriptor.h:170
Descriptor.h
ola::io
Classes for general I/O and event handling.
Definition Descriptor.cpp:49
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44