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
52b95149
Commit
52b95149
authored
Jul 12, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup defines and move sys header to .cpp file
parent
16dd62fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
43 deletions
+55
-43
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+37
-33
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+18
-10
No files found.
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
52b95149
...
...
@@ -18,11 +18,10 @@
#pragma once
#include <cstdint>
#include <string>
#include <thread>
#include <vector>
#include <string>
#include <cstdint>
#include "caf/config.hpp"
#include "caf/extend.hpp"
...
...
@@ -51,43 +50,48 @@
#include "caf/logger.hpp"
// poll xs epoll backend
#if !defined(CAF_LINUX) || defined(CAF_POLL_IMPL) // poll() multiplexer
# define CAF_POLL_MULTIPLEXER
# ifndef CAF_WINDOWS
# include <poll.h>
# endif
#else
# define CAF_EPOLL_MULTIPLEXER
# include <sys/epoll.h>
#endif
// Forward declaration of C types.
extern
"C"
{
// Forward declaration for Windows.
struct
pollfd
;
struct
epoll_event
;
}
// extern "C"
// Pick a backend for the multiplexer, depending on the settings in config.hpp.
#if !defined(CAF_LINUX) || defined(CAF_POLL_IMPL)
#define CAF_POLL_MULTIPLEXER
#else
#define CAF_EPOLL_MULTIPLEXER
#endif
namespace
caf
{
namespace
io
{
namespace
network
{
// poll vs epoll backend
#if !defined(CAF_LINUX) || defined(CAF_POLL_IMPL) // poll() multiplexer
extern
const
short
input_mask
;
extern
const
short
error_mask
;
extern
const
short
output_mask
;
class
event_handler
;
using
multiplexer_data
=
pollfd
;
using
multiplexer_poll_shadow_data
=
std
::
vector
<
event_handler
*>
;
#else
# define CAF_EPOLL_MULTIPLEXER
extern
const
int
input_mask
;
extern
const
int
error_mask
;
extern
const
int
output_mask
;
using
multiplexer_data
=
epoll_event
;
using
multiplexer_poll_shadow_data
=
native_socket
;
#endif
// Define type aliases based on backend type.
#ifdef CAF_POLL_MULTIPLEXER
using
event_mask_type
=
short
;
using
multiplexer_data
=
pollfd
;
using
multiplexer_poll_shadow_data
=
std
::
vector
<
event_handler
*>
;
#else // CAF_POLL_MULTIPLEXER
using
event_mask_type
=
int
;
using
multiplexer_data
=
epoll_event
;
using
multiplexer_poll_shadow_data
=
native_socket
;
#endif // CAF_POLL_MULTIPLEXER
/// Defines the bitmask for input (read) socket events.
extern
const
event_mask_type
input_mask
;
/// Defines the bitmask for output (write) socket events.
extern
const
event_mask_type
output_mask
;
///
Platform-specific native acceptor socket type
.
using
native_socket_acceptor
=
native_socket
;
///
Defines the bitmask for error socket events
.
extern
const
event_mask_type
error_mask
;
class
default_multiplexer
:
public
multiplexer
{
public:
...
...
@@ -189,7 +193,7 @@ private:
auto
bf
=
i
->
mask
;
i
->
mask
=
fun
(
op
,
bf
);
if
(
i
->
mask
==
bf
)
{
// didn't do a thing
// didn'
""
t do a thing
CAF_LOG_DEBUG
(
"squashing did not change the event"
);
}
else
if
(
i
->
mask
==
old_bf
)
{
// just turned into a nop
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
52b95149
...
...
@@ -18,6 +18,8 @@
#include "caf/io/network/default_multiplexer.hpp"
#include <utility>
#include "caf/config.hpp"
#include "caf/defaults.hpp"
#include "caf/optional.hpp"
...
...
@@ -67,7 +69,14 @@
# include <netinet/tcp.h>
# include <sys/socket.h>
# include <sys/types.h>
# include <utility>
#ifdef CAF_POLL_MULTIPLEXER
# include <poll.h>
#elif defined(CAF_EPOLL_MULTIPLEXER)
# include <sys/epoll.h>
#else
# error "neither CAF_POLL_MULTIPLEXER nor CAF_EPOLL_MULTIPLEXER defined"
#endif
#endif
using
std
::
string
;
...
...
@@ -109,7 +118,7 @@ namespace io {
namespace
network
{
// poll vs epoll backend
#if
!defined(CAF_LINUX) || defined(CAF_POLL_IMPL) // poll() multiplexer
#if
def CAF_POLL_MULTIPLEXER
# ifndef POLLRDHUP
# define POLLRDHUP POLLHUP
# endif
...
...
@@ -119,17 +128,16 @@ namespace network {
# ifdef CAF_WINDOWS
// From the MSDN: If the POLLPRI flag is set on a socket for the Microsoft
// Winsock provider, the WSAPoll function will fail.
const
short
input_mask
=
POLLIN
;
const
event_mask_type
input_mask
=
POLLIN
;
# else
const
short
input_mask
=
POLLIN
|
POLLPRI
;
const
event_mask_type
input_mask
=
POLLIN
|
POLLPRI
;
# endif
const
short
error_mask
=
POLLRDHUP
|
POLLERR
|
POLLHUP
|
POLLNVAL
;
const
short
output_mask
=
POLLOUT
;
const
event_mask_type
error_mask
=
POLLRDHUP
|
POLLERR
|
POLLHUP
|
POLLNVAL
;
const
event_mask_type
output_mask
=
POLLOUT
;
#else
# define CAF_EPOLL_MULTIPLEXER
const
int
input_mask
=
EPOLLIN
;
const
int
error_mask
=
EPOLLRDHUP
|
EPOLLERR
|
EPOLLHUP
;
const
int
output_mask
=
EPOLLOUT
;
const
event_mask_type
input_mask
=
EPOLLIN
;
const
event_mask_type
error_mask
=
EPOLLRDHUP
|
EPOLLERR
|
EPOLLHUP
;
const
event_mask_type
output_mask
=
EPOLLOUT
;
#endif
// -- Platform-dependent abstraction over epoll() or poll() --------------------
...
...
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