libassa
3.5.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
assa
Reactor.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
//------------------------------------------------------------------------------
3
// Reactor.h
4
//------------------------------------------------------------------------------
5
// Copyright (C) 1997-2002,2005 Vladislav Grinchenko
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Library General Public
9
// License as published by the Free Software Foundation; either
10
// version 2 of the License, or (at your option) any later version.
11
//------------------------------------------------------------------------------
12
// Created: 05/25/1999
13
//------------------------------------------------------------------------------
14
#ifndef REACTOR_H
15
#define REACTOR_H
16
17
#include <sys/time.h>
// select(2)
18
#include <map>
19
20
#if !defined(WIN32)
21
# include <sys/resource.h>
// getrlimit(2)
22
#endif
23
24
#include "
assa/EventHandler.h
"
25
#include "
assa/Singleton.h
"
26
#include "
assa/MaskSet.h
"
27
#include "
assa/TimerQueue.h
"
28
#include "
assa/TimerCountdown.h
"
29
30
namespace
ASSA {
31
57
class
Reactor
58
{
59
public
:
61
Reactor
();
62
64
~Reactor
();
65
76
TimerId
registerTimerHandler
(
EventHandler
* eh_,
77
const
TimeVal
& tv_,
78
const
std::string& name_ =
"<unknown>"
);
79
88
bool
registerIOHandler
(
EventHandler
* eh_,
89
handler_t
fd_,
90
EventType
et_ =
RWE_EVENTS
);
91
101
bool
removeHandler
(
EventHandler
* eh_,
EventType
et_ =
ALL_EVENTS
);
102
107
bool
removeTimerHandler
(
TimerId
id_);
108
114
bool
removeIOHandler
(
handler_t
fd_);
115
117
void
waitForEvents
(
void
);
118
127
void
waitForEvents
(
TimeVal
* tv_);
128
137
void
stopReactor
(
void
);
138
147
void
deactivate
(
void
);
148
149
private
:
150
Reactor
(
const
Reactor
&);
151
Reactor
&
operator=
(
const
Reactor
&);
152
153
private
:
154
typedef
std::map<u_int, EventHandler*>
Fd2Eh_Map_Type
;
155
typedef
Fd2Eh_Map_Type::iterator
Fd2Eh_Map_Iter
;
156
157
private
:
159
void
adjust_maxfdp1
(
handler_t
fd_);
160
162
bool
handleError
(
void
);
163
168
bool
dispatch
(
int
minimum_);
169
171
int
isAnyReady
(
void
);
172
177
bool
checkFDs
(
void
);
178
182
void
dispatchHandler
(
FdSet
& mask_,
183
Fd2Eh_Map_Type
& fdSet_,
184
EH_IO_Callback
callback_);
185
192
void
calculateTimeout
(
TimeVal
*& howlong_,
TimeVal
* maxwait_);
193
194
private
:
200
int
m_fd_setsize
;
201
206
handler_t
m_maxfd_plus1
;
207
209
bool
m_active
;
210
212
Fd2Eh_Map_Type
m_readSet
;
213
215
Fd2Eh_Map_Type
m_writeSet
;
216
218
Fd2Eh_Map_Type
m_exceptSet
;
219
221
MaskSet
m_waitSet
;
222
224
MaskSet
m_readySet
;
225
227
TimerQueue
m_tqueue
;
228
};
229
230
//-----------------------------------------------------------------------------
231
// Inline functions
232
//-----------------------------------------------------------------------------
233
234
inline
void
Reactor::deactivate
(
void
) {
m_active
=
false
; }
235
236
}
// end namespace ASSA
237
238
239
240
#endif
/* REACTOR_H */
Generated on Tue Jun 19 2012 07:40:08 for libassa by
1.8.1.1