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
580c5b28
Commit
580c5b28
authored
Mar 11, 2017
by
Constantin Rack
Committed by
GitHub
Mar 11, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2364 from somdoron/master
problem: zmq_poll is slow because FD is being created on every call
parents
651f81e8
f694a2d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
socket_poller.cpp
src/socket_poller.cpp
+17
-8
socket_poller.hpp
src/socket_poller.hpp
+1
-1
No files found.
src/socket_poller.cpp
View file @
580c5b28
...
...
@@ -33,6 +33,7 @@
zmq
::
socket_poller_t
::
socket_poller_t
()
:
tag
(
0xCAFEBABE
),
signaler
(
NULL
),
need_rebuild
(
true
),
use_signaler
(
false
),
poll_size
(
0
)
...
...
@@ -62,10 +63,15 @@ zmq::socket_poller_t::~socket_poller_t ()
size_t
thread_safe_size
=
sizeof
(
int
);
if
(
it
->
socket
->
getsockopt
(
ZMQ_THREAD_SAFE
,
&
thread_safe
,
&
thread_safe_size
)
==
0
&&
thread_safe
)
it
->
socket
->
remove_signaler
(
&
signaler
);
it
->
socket
->
remove_signaler
(
signaler
);
}
}
if
(
signaler
!=
NULL
)
{
delete
signaler
;
signaler
=
NULL
;
}
#if defined ZMQ_POLL_BASED_ON_POLL
if
(
pollfds
)
{
free
(
pollfds
);
...
...
@@ -95,7 +101,10 @@ int zmq::socket_poller_t::add (socket_base_t *socket_, void* user_data_, short e
return
-
1
;
if
(
thread_safe
)
{
if
(
socket_
->
add_signaler
(
&
signaler
)
==
-
1
)
if
(
signaler
==
NULL
)
signaler
=
new
signaler_t
();
if
(
socket_
->
add_signaler
(
signaler
)
==
-
1
)
return
-
1
;
}
...
...
@@ -193,7 +202,7 @@ int zmq::socket_poller_t::remove (socket_base_t *socket_)
size_t
thread_safe_size
=
sizeof
(
int
);
if
(
socket_
->
getsockopt
(
ZMQ_THREAD_SAFE
,
&
thread_safe
,
&
thread_safe_size
)
==
0
&&
thread_safe
)
socket_
->
remove_signaler
(
&
signaler
);
socket_
->
remove_signaler
(
signaler
);
return
0
;
}
...
...
@@ -264,7 +273,7 @@ int zmq::socket_poller_t::rebuild ()
if
(
use_signaler
)
{
item_nbr
=
1
;
pollfds
[
0
].
fd
=
signaler
.
get_fd
();
pollfds
[
0
].
fd
=
signaler
->
get_fd
();
pollfds
[
0
].
events
=
POLLIN
;
}
...
...
@@ -323,7 +332,7 @@ int zmq::socket_poller_t::rebuild ()
if
(
thread_safe
&&
it
->
events
)
{
use_signaler
=
true
;
FD_SET
(
signaler
.
get_fd
(),
&
pollset_in
);
FD_SET
(
signaler
->
get_fd
(),
&
pollset_in
);
poll_size
=
1
;
break
;
}
...
...
@@ -436,7 +445,7 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
// Receive the signal from pollfd
if
(
use_signaler
&&
pollfds
[
0
].
revents
&
POLLIN
)
signaler
.
recv
();
signaler
->
recv
();
// Check for the events.
int
found
=
0
;
...
...
@@ -596,8 +605,8 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_, int n_ev
break
;
}
if
(
use_signaler
&&
FD_ISSET
(
signaler
.
get_fd
(),
&
inset
))
signaler
.
recv
();
if
(
use_signaler
&&
FD_ISSET
(
signaler
->
get_fd
(),
&
inset
))
signaler
->
recv
();
// Check for the events.
int
found
=
0
;
...
...
src/socket_poller.hpp
View file @
580c5b28
...
...
@@ -87,7 +87,7 @@ namespace zmq
uint32_t
tag
;
// Signaler used for thread safe sockets polling
signaler_t
signaler
;
signaler_t
*
signaler
;
typedef
struct
item_t
{
socket_base_t
*
socket
;
...
...
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