Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
f182d377
Commit
f182d377
authored
Jul 16, 2018
by
Dominik Charousset
Committed by
Dominik Charousset
Jul 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose socket count and internal event handling
parent
2cae44fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+6
-0
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+18
-11
No files found.
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
f182d377
...
@@ -167,6 +167,12 @@ public:
...
@@ -167,6 +167,12 @@ public:
/// Get the next id to create a new datagram handle
/// Get the next id to create a new datagram handle
int64_t
next_endpoint_id
();
int64_t
next_endpoint_id
();
/// Returns the number of socket handlers.
size_t
num_socket_handlers
()
const
noexcept
;
/// Run all pending events generated from calls to `add` or `del`.
void
handle_internal_events
();
private:
private:
/// Calls `epoll`, `kqueue`, or `poll` with or without blocking.
/// Calls `epoll`, `kqueue`, or `poll` with or without blocking.
bool
poll_once_impl
(
bool
block
);
bool
poll_once_impl
(
bool
block
);
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
f182d377
...
@@ -205,10 +205,7 @@ namespace network {
...
@@ -205,10 +205,7 @@ namespace network {
auto
fd
=
ptr
?
ptr
->
fd
()
:
pipe_
.
first
;
auto
fd
=
ptr
?
ptr
->
fd
()
:
pipe_
.
first
;
handle_socket_event
(
fd
,
static_cast
<
int
>
(
iter
->
events
),
ptr
);
handle_socket_event
(
fd
,
static_cast
<
int
>
(
iter
->
events
),
ptr
);
}
}
for
(
auto
&
me
:
events_
)
{
handle_internal_events
();
handle
(
me
);
}
events_
.
clear
();
return
true
;
return
true
;
}
}
}
}
...
@@ -285,6 +282,10 @@ namespace network {
...
@@ -285,6 +282,10 @@ namespace network {
}
}
}
}
size_t
default_multiplexer
::
num_socket_handlers
()
const
noexcept
{
return
shadow_
;
}
#else // CAF_EPOLL_MULTIPLEXER
#else // CAF_EPOLL_MULTIPLEXER
// Let's be honest: the API of poll() sucks. When dealing with 1000 sockets
// Let's be honest: the API of poll() sucks. When dealing with 1000 sockets
...
@@ -383,11 +384,8 @@ namespace network {
...
@@ -383,11 +384,8 @@ namespace network {
// operations possible on the socket
// operations possible on the socket
handle_socket_event
(
e
.
fd
,
e
.
mask
,
e
.
ptr
);
handle_socket_event
(
e
.
fd
,
e
.
mask
,
e
.
ptr
);
}
}
CAF_LOG_DEBUG
(
CAF_ARG
(
events_
.
size
()));
poll_res
.
clear
();
poll_res
.
clear
();
for
(
auto
&
me
:
events_
)
handle_internal_events
();
handle
(
me
);
events_
.
clear
();
return
true
;
return
true
;
}
}
}
}
...
@@ -456,6 +454,10 @@ namespace network {
...
@@ -456,6 +454,10 @@ namespace network {
}
}
}
}
size_t
default_multiplexer
::
num_socket_handlers
()
const
noexcept
{
return
pollset_
.
size
();
}
#endif // CAF_EPOLL_MULTIPLEXER
#endif // CAF_EPOLL_MULTIPLEXER
// -- Helper functions for defining bitmasks of event handlers -----------------
// -- Helper functions for defining bitmasks of event handlers -----------------
...
@@ -604,9 +606,7 @@ bool default_multiplexer::poll_once(bool block) {
...
@@ -604,9 +606,7 @@ bool default_multiplexer::poll_once(bool block) {
internally_posted_
.
swap
(
xs
);
internally_posted_
.
swap
(
xs
);
for
(
auto
&
ptr
:
xs
)
for
(
auto
&
ptr
:
xs
)
resume
(
std
::
move
(
ptr
));
resume
(
std
::
move
(
ptr
));
for
(
auto
&
me
:
events_
)
handle_internal_events
();
handle
(
me
);
events_
.
clear
();
// Try to swap back to internall_posted_ to re-use allocated memory.
// Try to swap back to internall_posted_ to re-use allocated memory.
if
(
internally_posted_
.
empty
())
{
if
(
internally_posted_
.
empty
())
{
xs
.
swap
(
internally_posted_
);
xs
.
swap
(
internally_posted_
);
...
@@ -736,6 +736,13 @@ int64_t default_multiplexer::next_endpoint_id() {
...
@@ -736,6 +736,13 @@ int64_t default_multiplexer::next_endpoint_id() {
return
servant_ids_
++
;
return
servant_ids_
++
;
}
}
void
default_multiplexer
::
handle_internal_events
()
{
CAF_LOG_TRACE
(
CAF_ARG2
(
"num-events"
,
events_
.
size
()));
for
(
auto
&
e
:
events_
)
handle
(
e
);
events_
.
clear
();
}
// -- Related helper functions -------------------------------------------------
// -- Related helper functions -------------------------------------------------
template
<
int
Family
>
template
<
int
Family
>
...
...
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