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
95a30652
Commit
95a30652
authored
Feb 11, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New `ccall` utility and coding style nitpicks
parent
41957aa3
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
141 additions
and
177 deletions
+141
-177
libcaf_io/caf/io/network/acceptor_manager.hpp
libcaf_io/caf/io/network/acceptor_manager.hpp
+0
-3
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+27
-53
libcaf_io/caf/io/network/interfaces.hpp
libcaf_io/caf/io/network/interfaces.hpp
+5
-5
libcaf_io/caf/io/network/manager.hpp
libcaf_io/caf/io/network/manager.hpp
+1
-6
libcaf_io/caf/io/network/stream_manager.hpp
libcaf_io/caf/io/network/stream_manager.hpp
+1
-4
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+106
-105
libcaf_io/src/interfaces.cpp
libcaf_io/src/interfaces.cpp
+1
-1
No files found.
libcaf_io/caf/io/network/acceptor_manager.hpp
View file @
95a30652
...
...
@@ -31,9 +31,7 @@ namespace network {
* callbacks for incoming connections as well as for error handling.
*/
class
acceptor_manager
:
public
manager
{
public:
~
acceptor_manager
();
/**
...
...
@@ -41,7 +39,6 @@ class acceptor_manager : public manager {
* a new connection is awaiting acceptance.
*/
virtual
void
new_connection
()
=
0
;
};
}
// namespace network
...
...
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
95a30652
...
...
@@ -153,12 +153,6 @@ void nonblocking(native_socket fd, bool new_value);
*/
std
::
pair
<
native_socket
,
native_socket
>
create_pipe
();
/**
* Throws network_error with given error message and
* the platform-specific error code if `add_errno` is `true`.
*/
void
throw_io_failure
(
const
char
*
what
,
bool
add_errno
=
true
);
/**
* Returns true if `fd` is configured as nodelay socket.
* @throws network_error
...
...
@@ -222,6 +216,11 @@ class event_handler {
*/
virtual
void
removed_from_loop
(
operation
op
)
=
0
;
/**
* Returns the native socket handle for this handler.
*/
virtual
native_socket
fd
()
const
=
0
;
/**
* Returns the `multiplexer` this acceptor belongs to.
*/
...
...
@@ -243,11 +242,6 @@ class event_handler {
m_eventbf
=
value
;
}
/**
* Returns the native socket handle for this handler.
*/
virtual
native_socket
fd
()
const
=
0
;
protected:
default_multiplexer
&
m_backend
;
int
m_eventbf
;
...
...
@@ -294,12 +288,10 @@ class default_socket {
using
default_socket_acceptor
=
default_socket
;
class
default_multiplexer
:
public
multiplexer
{
public:
friend
class
io
::
middleman
;
// disambiguate reference
friend
class
supervisor
;
public:
struct
event
{
native_socket
fd
;
int
mask
;
...
...
@@ -356,7 +348,6 @@ class default_multiplexer : public multiplexer {
void
del
(
operation
op
,
native_socket
fd
,
event_handler
*
ptr
);
private:
// platform-dependent additional initialization code
void
init
();
...
...
@@ -417,20 +408,18 @@ class default_multiplexer : public multiplexer {
std
::
vector
<
event
>
m_events
;
// always sorted by .fd
multiplexer_poll_shadow_data
m_shadow
;
std
::
pair
<
native_socket
,
native_socket
>
m_pipe
;
std
::
thread
::
id
m_tid
;
};
default_multiplexer
&
get_multiplexer_singleton
();
template
<
class
T
>
inline
connection_handle
conn_hdl_from_socket
(
const
T
&
sock
)
{
connection_handle
conn_hdl_from_socket
(
const
T
&
sock
)
{
return
connection_handle
::
from_int
(
int64_from_native_socket
(
sock
.
native_handle
()));
}
template
<
class
T
>
inline
accept_handle
accept_hdl_from_socket
(
const
T
&
sock
)
{
accept_handle
accept_hdl_from_socket
(
const
T
&
sock
)
{
return
accept_handle
::
from_int
(
int64_from_native_socket
(
sock
.
native_handle
()));
}
...
...
@@ -461,17 +450,10 @@ class stream : public event_handler {
configure_read
(
receive_policy
::
at_most
(
1024
));
}
/**
* Returns the `multiplexer` this stream belongs to.
*/
inline
default_multiplexer
&
backend
()
{
return
static_cast
<
default_multiplexer
&>
(
m_sock
.
backend
());
}
/**
* Returns the IO socket.
*/
inline
Socket
&
socket_handle
()
{
Socket
&
socket_handle
()
{
return
m_sock
;
}
...
...
@@ -501,8 +483,7 @@ class stream : public event_handler {
}
/**
* Configures how much data will be provided
* for the next `consume` callback.
* Configures how much data will be provided for the next `consume` callback.
* @warning Must not be called outside the IO multiplexers event loop
* once the stream has been started.
*/
...
...
@@ -513,7 +494,7 @@ class stream : public event_handler {
/**
* Copies data to the write buffer.
* @
note
Not thread safe.
* @
warning
Not thread safe.
*/
void
write
(
const
void
*
buf
,
size_t
num_bytes
)
{
CAF_LOG_TRACE
(
"num_bytes: "
<<
num_bytes
);
...
...
@@ -560,7 +541,7 @@ class stream : public event_handler {
backend
().
del
(
operation
::
read
,
m_sock
.
fd
(),
this
);
}
void
handle_event
(
operation
op
)
{
void
handle_event
(
operation
op
)
override
{
CAF_LOG_TRACE
(
"op = "
<<
static_cast
<
int
>
(
op
));
switch
(
op
)
{
case
operation
:
:
read
:
{
...
...
@@ -609,7 +590,6 @@ class stream : public event_handler {
}
}
protected:
native_socket
fd
()
const
override
{
return
m_sock
.
fd
();
}
...
...
@@ -657,20 +637,20 @@ class stream : public event_handler {
}
// reading & writing
Socket
m_sock
;
Socket
m_sock
;
// reading
manager_ptr
m_reader
;
size_t
m_threshold
;
size_t
m_collected
;
size_t
m_max
;
manager_ptr
m_reader
;
size_t
m_threshold
;
size_t
m_collected
;
size_t
m_max
;
receive_policy_flag
m_rd_flag
;
buffer_type
m_rd_buf
;
buffer_type
m_rd_buf
;
// writing
manager_ptr
m_writer
;
bool
m_writing
;
size_t
m_written
;
buffer_type
m_wr_buf
;
buffer_type
m_wr_offline_buf
;
manager_ptr
m_writer
;
bool
m_writing
;
size_t
m_written
;
buffer_type
m_wr_buf
;
buffer_type
m_wr_offline_buf
;
};
/**
...
...
@@ -678,9 +658,7 @@ class stream : public event_handler {
*/
template
<
class
SocketAcceptor
>
class
acceptor
:
public
event_handler
{
public:
using
socket_type
=
typename
SocketAcceptor
::
socket_type
;
/**
...
...
@@ -703,7 +681,7 @@ class acceptor : public event_handler {
/**
* Returns the IO socket.
*/
inline
SocketAcceptor
&
socket_handle
()
{
SocketAcceptor
&
socket_handle
()
{
return
m_accept_sock
;
}
...
...
@@ -711,7 +689,7 @@ class acceptor : public event_handler {
* Returns the accepted socket. This member function should
* be called only from the `new_connection` callback.
*/
inline
socket_type
&
accepted_socket
()
{
socket_type
&
accepted_socket
()
{
return
m_sock
;
}
...
...
@@ -767,18 +745,14 @@ class acceptor : public event_handler {
}
}
protected:
native_socket
fd
()
const
override
{
return
m_accept_sock
.
fd
();
}
private:
manager_ptr
m_mgr
;
manager_ptr
m_mgr
;
SocketAcceptor
m_accept_sock
;
socket_type
m_sock
;
socket_type
m_sock
;
};
native_socket
new_tcp_connection_impl
(
const
std
::
string
&
,
uint16_t
,
...
...
libcaf_io/caf/io/network/interfaces.hpp
View file @
95a30652
...
...
@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_NETWORK_
ADDRESS
ES_HPP
#define CAF_IO_NETWORK_
ADDRESS
ES_HPP
#ifndef CAF_IO_NETWORK_
INTERFAC
ES_HPP
#define CAF_IO_NETWORK_
INTERFAC
ES_HPP
#include <map>
#include <vector>
...
...
@@ -61,14 +61,14 @@ class interfaces {
bool
include_localhost
=
true
);
/**
* Returns
`pair<string, protocol>` for given host address
.
* Returns
a native IPv4 or IPv6 translation of `host`
.
**/
static
optional
<
std
::
pair
<
std
::
string
,
protocol
>>
get_addrinfo_of_host
(
const
std
::
string
&
host
,
optional
<
protocol
>
preferred
=
none
);
native_address
(
const
std
::
string
&
host
,
optional
<
protocol
>
preferred
=
none
);
};
}
// namespace network
}
// namespace io
}
// namespace caf
#endif // CAF_IO_NETWORK_
ADDRESS
ES_HPP
#endif // CAF_IO_NETWORK_
INTERFAC
ES_HPP
libcaf_io/caf/io/network/manager.hpp
View file @
95a30652
...
...
@@ -35,7 +35,7 @@ namespace network {
*/
class
manager
:
public
ref_counted
{
public:
virtual
~
manager
();
~
manager
();
/**
* Causes the manager to stop read operations on its IO device.
...
...
@@ -49,11 +49,6 @@ class manager : public ref_counted {
virtual
void
io_failure
(
operation
op
)
=
0
;
};
/**
* @relates manager
*/
using
manager_ptr
=
intrusive_ptr
<
manager
>
;
}
// namespace network
}
// namespace io
}
// namespace caf
...
...
libcaf_io/caf/io/network/stream_manager.hpp
View file @
95a30652
...
...
@@ -33,16 +33,13 @@ namespace network {
* for incoming data as well as for error handling.
*/
class
stream_manager
:
public
manager
{
public:
virtual
~
stream_manager
();
~
stream_manager
();
/**
* Called by the underlying IO device whenever it received data.
*/
virtual
void
consume
(
const
void
*
data
,
size_t
num_bytes
)
=
0
;
};
}
// namespace network
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
95a30652
This diff is collapsed.
Click to expand it.
libcaf_io/src/interfaces.cpp
View file @
95a30652
...
...
@@ -145,7 +145,7 @@ std::vector<std::string> interfaces::list_addresses(protocol proc,
}
optional
<
std
::
pair
<
std
::
string
,
protocol
>>
interfaces
::
get_addrinfo_of_host
(
const
std
::
string
&
host
,
interfaces
::
native_address
(
const
std
::
string
&
host
,
optional
<
protocol
>
preferred
)
{
addrinfo
hint
;
memset
(
&
hint
,
0
,
sizeof
(
hint
));
...
...
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