Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
cf815e8c
Commit
cf815e8c
authored
Sep 26, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new interfaces for timers; the implementation is not changed yet
parent
be79a9fb
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
48 additions
and
42 deletions
+48
-42
config.hpp
src/config.hpp
+4
-0
devpoll.cpp
src/devpoll.cpp
+3
-3
devpoll.hpp
src/devpoll.hpp
+3
-4
epoll.cpp
src/epoll.cpp
+3
-3
epoll.hpp
src/epoll.hpp
+2
-2
i_poll_events.hpp
src/i_poll_events.hpp
+1
-1
io_object.cpp
src/io_object.cpp
+5
-5
io_object.hpp
src/io_object.hpp
+3
-3
io_thread.cpp
src/io_thread.cpp
+1
-1
io_thread.hpp
src/io_thread.hpp
+1
-1
kqueue.cpp
src/kqueue.cpp
+3
-3
kqueue.hpp
src/kqueue.hpp
+2
-2
poll.cpp
src/poll.cpp
+3
-3
poll.hpp
src/poll.hpp
+2
-2
select.cpp
src/select.cpp
+3
-3
select.hpp
src/select.hpp
+2
-2
zmq_connecter.cpp
src/zmq_connecter.cpp
+4
-4
zmq_connecter.hpp
src/zmq_connecter.hpp
+3
-0
No files found.
src/config.hpp
View file @
cf815e8c
...
...
@@ -69,9 +69,13 @@ namespace zmq
// Maximum number of events the I/O thread can process in one go.
max_io_events
=
256
,
// TODO: To be removed
// Maximal wait time for a timer (milliseconds).
max_timer_period
=
100
,
// How long to wait (milliseconds) till reattempting to connect.
reconnect_period
=
100
,
// Maximal delay to process command in API thread (in CPU ticks).
// 3,000,000 ticks equals to 1 - 2 milliseconds on current CPUs.
// Note that delay is only applied when there is continuous stream of
...
...
src/devpoll.cpp
View file @
cf815e8c
...
...
@@ -128,12 +128,12 @@ void zmq::devpoll_t::reset_pollout (handle_t handle_)
devpoll_ctl
(
handle_
,
fd_table
[
handle_
].
events
);
}
void
zmq
::
devpoll_t
::
add_timer
(
i
_poll_events
*
events
_
)
void
zmq
::
devpoll_t
::
add_timer
(
i
nt
timeout_
,
i_poll_events
*
events_
,
int
id
_
)
{
timers
.
push_back
(
events_
);
}
void
zmq
::
devpoll_t
::
cancel_timer
(
i_poll_events
*
events_
)
void
zmq
::
devpoll_t
::
cancel_timer
(
i_poll_events
*
events_
,
int
id_
)
{
timers_t
::
iterator
it
=
std
::
find
(
timers
.
begin
(),
timers
.
end
(),
events_
);
if
(
it
!=
timers
.
end
())
...
...
@@ -190,7 +190,7 @@ void zmq::devpoll_t::loop ()
// Trigger all the timers.
for
(
timers_t
::
iterator
it
=
t
.
begin
();
it
!=
t
.
end
();
it
++
)
(
*
it
)
->
timer_event
();
(
*
it
)
->
timer_event
(
-
1
);
continue
;
}
...
...
src/devpoll.hpp
View file @
cf815e8c
...
...
@@ -33,8 +33,7 @@
namespace
zmq
{
// Implements socket polling mechanism using the Solaris-specific
// "/dev/poll" interface.
// Implements socket polling mechanism using the "/dev/poll" interface.
class
devpoll_t
{
...
...
@@ -52,8 +51,8 @@ namespace zmq
void
reset_pollin
(
handle_t
handle_
);
void
set_pollout
(
handle_t
handle_
);
void
reset_pollout
(
handle_t
handle_
);
void
add_timer
(
struct
i_poll_events
*
events
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
);
void
add_timer
(
int
timeout_
,
struct
i_poll_events
*
events_
,
int
id
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
,
int
id_
);
int
get_load
();
void
start
();
void
stop
();
...
...
src/epoll.cpp
View file @
cf815e8c
...
...
@@ -120,12 +120,12 @@ void zmq::epoll_t::reset_pollout (handle_t handle_)
errno_assert
(
rc
!=
-
1
);
}
void
zmq
::
epoll_t
::
add_timer
(
i
_poll_events
*
events
_
)
void
zmq
::
epoll_t
::
add_timer
(
i
nt
timeout_
,
i_poll_events
*
events_
,
int
id
_
)
{
timers
.
push_back
(
events_
);
}
void
zmq
::
epoll_t
::
cancel_timer
(
i_poll_events
*
events_
)
void
zmq
::
epoll_t
::
cancel_timer
(
i_poll_events
*
events_
,
int
id_
)
{
timers_t
::
iterator
it
=
std
::
find
(
timers
.
begin
(),
timers
.
end
(),
events_
);
if
(
it
==
timers
.
end
())
...
...
@@ -175,7 +175,7 @@ void zmq::epoll_t::loop ()
// Trigger all the timers.
for
(
timers_t
::
iterator
it
=
t
.
begin
();
it
!=
t
.
end
();
it
++
)
(
*
it
)
->
timer_event
();
(
*
it
)
->
timer_event
(
-
1
);
continue
;
}
...
...
src/epoll.hpp
View file @
cf815e8c
...
...
@@ -53,8 +53,8 @@ namespace zmq
void
reset_pollin
(
handle_t
handle_
);
void
set_pollout
(
handle_t
handle_
);
void
reset_pollout
(
handle_t
handle_
);
void
add_timer
(
struct
i_poll_events
*
events
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
);
void
add_timer
(
int
timeout_
,
struct
i_poll_events
*
events_
,
int
id
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
,
int
id_
);
int
get_load
();
void
start
();
void
stop
();
...
...
src/i_poll_events.hpp
View file @
cf815e8c
...
...
@@ -37,7 +37,7 @@ namespace zmq
virtual
void
out_event
()
=
0
;
// Called when timer expires.
virtual
void
timer_event
()
=
0
;
virtual
void
timer_event
(
int
id_
)
=
0
;
};
}
...
...
src/io_object.cpp
View file @
cf815e8c
...
...
@@ -80,14 +80,14 @@ void zmq::io_object_t::reset_pollout (handle_t handle_)
poller
->
reset_pollout
(
handle_
);
}
void
zmq
::
io_object_t
::
add_timer
()
void
zmq
::
io_object_t
::
add_timer
(
int
timeout_
,
int
id_
)
{
poller
->
add_timer
(
t
his
);
poller
->
add_timer
(
t
imeout_
,
this
,
id_
);
}
void
zmq
::
io_object_t
::
cancel_timer
()
void
zmq
::
io_object_t
::
cancel_timer
(
int
id_
)
{
poller
->
cancel_timer
(
this
);
poller
->
cancel_timer
(
this
,
id_
);
}
void
zmq
::
io_object_t
::
in_event
()
...
...
@@ -100,7 +100,7 @@ void zmq::io_object_t::out_event ()
zmq_assert
(
false
);
}
void
zmq
::
io_object_t
::
timer_event
()
void
zmq
::
io_object_t
::
timer_event
(
int
id_
)
{
zmq_assert
(
false
);
}
src/io_object.hpp
View file @
cf815e8c
...
...
@@ -56,13 +56,13 @@ namespace zmq
void
reset_pollin
(
handle_t
handle_
);
void
set_pollout
(
handle_t
handle_
);
void
reset_pollout
(
handle_t
handle_
);
void
add_timer
();
void
cancel_timer
();
void
add_timer
(
int
timout_
,
int
id_
);
void
cancel_timer
(
int
id_
);
// i_poll_events interface implementation.
void
in_event
();
void
out_event
();
void
timer_event
();
void
timer_event
(
int
id_
);
private
:
...
...
src/io_thread.cpp
View file @
cf815e8c
...
...
@@ -89,7 +89,7 @@ void zmq::io_thread_t::out_event ()
zmq_assert
(
false
);
}
void
zmq
::
io_thread_t
::
timer_event
()
void
zmq
::
io_thread_t
::
timer_event
(
int
id_
)
{
// No timers here. This function is never called.
zmq_assert
(
false
);
...
...
src/io_thread.hpp
View file @
cf815e8c
...
...
@@ -56,7 +56,7 @@ namespace zmq
// i_poll_events implementation.
void
in_event
();
void
out_event
();
void
timer_event
();
void
timer_event
(
int
id_
);
// Used by io_objects to retrieve the assciated poller object.
poller_t
*
get_poller
();
...
...
src/kqueue.cpp
View file @
cf815e8c
...
...
@@ -132,12 +132,12 @@ void zmq::kqueue_t::reset_pollout (handle_t handle_)
kevent_delete
(
pe
->
fd
,
EVFILT_WRITE
);
}
void
zmq
::
kqueue_t
::
add_timer
(
i
_poll_events
*
events
_
)
void
zmq
::
kqueue_t
::
add_timer
(
i
nt
timeout_
,
i_poll_events
*
events_
,
int
id
_
)
{
timers
.
push_back
(
events_
);
}
void
zmq
::
kqueue_t
::
cancel_timer
(
i_poll_events
*
events_
)
void
zmq
::
kqueue_t
::
cancel_timer
(
i_poll_events
*
events_
,
int
id_
)
{
timers_t
::
iterator
it
=
std
::
find
(
timers
.
begin
(),
timers
.
end
(),
events_
);
if
(
it
!=
timers
.
end
())
...
...
@@ -186,7 +186,7 @@ void zmq::kqueue_t::loop ()
// Trigger all the timers.
for
(
timers_t
::
iterator
it
=
t
.
begin
();
it
!=
t
.
end
();
it
++
)
(
*
it
)
->
timer_event
();
(
*
it
)
->
timer_event
(
-
1
);
continue
;
}
...
...
src/kqueue.hpp
View file @
cf815e8c
...
...
@@ -53,8 +53,8 @@ namespace zmq
void
reset_pollin
(
handle_t
handle_
);
void
set_pollout
(
handle_t
handle_
);
void
reset_pollout
(
handle_t
handle_
);
void
add_timer
(
struct
i_poll_events
*
events
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
);
void
add_timer
(
int
timeout_
,
struct
i_poll_events
*
events_
,
int
id
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
,
int
id_
);
int
get_load
();
void
start
();
void
stop
();
...
...
src/poll.cpp
View file @
cf815e8c
...
...
@@ -112,12 +112,12 @@ void zmq::poll_t::reset_pollout (handle_t handle_)
pollset
[
index
].
events
&=
~
((
short
)
POLLOUT
);
}
void
zmq
::
poll_t
::
add_timer
(
i
_poll_events
*
events
_
)
void
zmq
::
poll_t
::
add_timer
(
i
nt
timeout_
,
i_poll_events
*
events_
,
int
id
_
)
{
timers
.
push_back
(
events_
);
}
void
zmq
::
poll_t
::
cancel_timer
(
i_poll_events
*
events_
)
void
zmq
::
poll_t
::
cancel_timer
(
i_poll_events
*
events_
,
int
id_
)
{
timers_t
::
iterator
it
=
std
::
find
(
timers
.
begin
(),
timers
.
end
(),
events_
);
if
(
it
!=
timers
.
end
())
...
...
@@ -160,7 +160,7 @@ void zmq::poll_t::loop ()
// Trigger all the timers.
for
(
timers_t
::
iterator
it
=
t
.
begin
();
it
!=
t
.
end
();
it
++
)
(
*
it
)
->
timer_event
();
(
*
it
)
->
timer_event
(
-
1
);
continue
;
}
...
...
src/poll.hpp
View file @
cf815e8c
...
...
@@ -58,8 +58,8 @@ namespace zmq
void
reset_pollin
(
handle_t
handle_
);
void
set_pollout
(
handle_t
handle_
);
void
reset_pollout
(
handle_t
handle_
);
void
add_timer
(
struct
i_poll_events
*
events
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
);
void
add_timer
(
int
timeout_
,
struct
i_poll_events
*
events_
,
int
id
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
,
int
id_
);
int
get_load
();
void
start
();
void
stop
();
...
...
src/select.cpp
View file @
cf815e8c
...
...
@@ -136,12 +136,12 @@ void zmq::select_t::reset_pollout (handle_t handle_)
FD_CLR
(
handle_
,
&
source_set_out
);
}
void
zmq
::
select_t
::
add_timer
(
i
_poll_events
*
events
_
)
void
zmq
::
select_t
::
add_timer
(
i
nt
timeout_
,
i_poll_events
*
events_
,
int
id
_
)
{
timers
.
push_back
(
events_
);
}
void
zmq
::
select_t
::
cancel_timer
(
i_poll_events
*
events_
)
void
zmq
::
select_t
::
cancel_timer
(
i_poll_events
*
events_
,
int
id_
)
{
timers_t
::
iterator
it
=
std
::
find
(
timers
.
begin
(),
timers
.
end
(),
events_
);
if
(
it
!=
timers
.
end
())
...
...
@@ -199,7 +199,7 @@ void zmq::select_t::loop ()
// Trigger all the timers.
for
(
timers_t
::
iterator
it
=
t
.
begin
();
it
!=
t
.
end
();
it
++
)
(
*
it
)
->
timer_event
();
(
*
it
)
->
timer_event
(
-
1
);
continue
;
}
...
...
src/select.hpp
View file @
cf815e8c
...
...
@@ -60,8 +60,8 @@ namespace zmq
void
reset_pollin
(
handle_t
handle_
);
void
set_pollout
(
handle_t
handle_
);
void
reset_pollout
(
handle_t
handle_
);
void
add_timer
(
struct
i_poll_events
*
events
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
);
void
add_timer
(
int
timeout_
,
struct
i_poll_events
*
events_
,
int
id
_
);
void
cancel_timer
(
struct
i_poll_events
*
events_
,
int
id_
);
int
get_load
();
void
start
();
void
stop
();
...
...
src/zmq_connecter.cpp
View file @
cf815e8c
...
...
@@ -42,7 +42,7 @@ zmq::zmq_connecter_t::zmq_connecter_t (class io_thread_t *io_thread_,
zmq
::
zmq_connecter_t
::~
zmq_connecter_t
()
{
if
(
wait
)
cancel_timer
();
cancel_timer
(
reconnect_timer_id
);
if
(
handle_valid
)
rm_fd
(
handle
);
}
...
...
@@ -50,7 +50,7 @@ zmq::zmq_connecter_t::~zmq_connecter_t ()
void
zmq
::
zmq_connecter_t
::
process_plug
()
{
if
(
wait
)
add_timer
();
add_timer
(
reconnect_period
,
reconnect_timer_id
);
else
start_connecting
();
}
...
...
@@ -73,7 +73,7 @@ void zmq::zmq_connecter_t::out_event ()
if
(
fd
==
retired_fd
)
{
tcp_connecter
.
close
();
wait
=
true
;
add_timer
();
add_timer
(
reconnect_period
,
reconnect_timer_id
);
return
;
}
...
...
@@ -121,5 +121,5 @@ void zmq::zmq_connecter_t::start_connecting ()
// Handle any other error condition by eventual reconnect.
wait
=
true
;
add_timer
();
add_timer
(
reconnect_period
,
reconnect_timer_id
);
}
src/zmq_connecter.hpp
View file @
cf815e8c
...
...
@@ -42,6 +42,9 @@ namespace zmq
private
:
// ID of the timer used to delay the reconnection.
enum
{
reconnect_timer_id
=
1
};
// Handlers for incoming commands.
void
process_plug
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment