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
1f9aa431
Commit
1f9aa431
authored
Jul 14, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial scaffold for UDP abstraction
parent
bb953534
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
12 deletions
+150
-12
cppa/io/broker.hpp
cppa/io/broker.hpp
+36
-1
cppa/io/datagram_endpoint.hpp
cppa/io/datagram_endpoint.hpp
+34
-0
cppa/io/datagram_source_handle.hpp
cppa/io/datagram_source_handle.hpp
+51
-0
cppa/io/network.hpp
cppa/io/network.hpp
+6
-0
cppa/system_messages.hpp
cppa/system_messages.hpp
+23
-11
No files found.
cppa/io/broker.hpp
View file @
1f9aa431
...
@@ -199,13 +199,42 @@ class broker : public extend<local_actor>::
...
@@ -199,13 +199,42 @@ class broker : public extend<local_actor>::
*/
*/
buffer_type
&
wr_buf
(
connection_handle
hdl
);
buffer_type
&
wr_buf
(
connection_handle
hdl
);
void
write
(
connection_handle
hdl
,
size_t
buf_size
,
const
void
*
buf
);
/**
* @brief Writes @p data into the buffer for given connection.
*/
void
write
(
connection_handle
hdl
,
size_t
data_size
,
const
void
*
data
);
/**
/**
* @brief Sends the content of the buffer for given connection.
* @brief Sends the content of the buffer for given connection.
*/
*/
void
flush
(
connection_handle
hdl
);
void
flush
(
connection_handle
hdl
);
struct
datagram_handle
{
buffer_type
*
buf
;
datagram_endpoint
dest
;
};
/**
* @brief Returns a new buffer for the given endpoint. Note that each call
* to this member function will return a new buffer.
*/
datagram_handle
new_datagram
(
datagram_endpoint
ep
);
/**
* @brief Sends the datagram.
*/
void
send_datagram
(
datagram_handle
ep
);
inline
void
send_datagram
(
datagram_endpoint
ep
,
size_t
data_size
,
const
void
*
data
)
{
auto
hdl
=
new_datagram
(
ep
);
auto
first
=
reinterpret_cast
<
const
char
*>
(
data
);
auto
last
=
first
+
data_size
;
hdl
.
buf
->
insert
(
hdl
.
buf
->
end
(),
first
,
last
);
send_datagram
(
hdl
);
}
/**
/**
* @brief Returns the number of open connections.
* @brief Returns the number of open connections.
*/
*/
...
@@ -338,6 +367,12 @@ class broker : public extend<local_actor>::
...
@@ -338,6 +367,12 @@ class broker : public extend<local_actor>::
return
ptr
->
hdl
();
return
ptr
->
hdl
();
}
}
template
<
class
DatagramSocket
>
datagram_source_handle
add_datagram_source
(
DatagramSocket
sock
)
{
// ToDo: implement me
return
invalid_datagram_source_handle
;
}
void
enqueue
(
const
actor_addr
&
,
message_id
,
message
,
void
enqueue
(
const
actor_addr
&
,
message_id
,
message
,
execution_unit
*
)
override
;
execution_unit
*
)
override
;
...
...
cppa/io/datagram_endpoint.hpp
0 → 100644
View file @
1f9aa431
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the Boost Software License, Version 1.0. See *
* accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt *
\******************************************************************************/
#ifndef CPPA_IO_DATAGRAM_ENDPOINT_HPP
#define CPPA_IO_DATAGRAM_ENDPOINT_HPP
#include <memory>
#include "cppa/io/network.hpp"
namespace
cppa
{
namespace
io
{
using
datagram_endpoint
=
std
::
shared_ptr
<
network
::
datagram_endpoint_data
>
;
}
// namespace io
}
// namespace cppa
#endif // CPPA_IO_DATAGRAM_ENDPOINT_HPP
cppa/io/datagram_source_handle.hpp
0 → 100644
View file @
1f9aa431
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the Boost Software License, Version 1.0. See *
* accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt *
\******************************************************************************/
#ifndef CPPA_IO_DATAGRAM_SOURCE_HANDLE_HPP
#define CPPA_IO_DATAGRAM_SOURCE_HANDLE_HPP
#include "cppa/io_handle.hpp"
namespace
cppa
{
namespace
io
{
/**
* @brief Generic handle type for identifying connections.
*/
class
datagram_source_handle
:
public
io_handle
<
datagram_source_handle
>
{
friend
class
io_handle
<
datagram_source_handle
>
;
using
super
=
io_handle
<
datagram_source_handle
>
;
public:
constexpr
datagram_source_handle
()
{
}
private:
inline
datagram_source_handle
(
int64_t
handle_id
)
:
super
{
handle_id
}
{
}
};
constexpr
datagram_source_handle
invalid_datagram_source_handle
{};
}
// namespace io
}
// namespace cppa
#endif // CPPA_IO_DATAGRAM_SOURCE_HANDLE_HPP
cppa/io/network.hpp
View file @
1f9aa431
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
#else
#else
# include <unistd.h>
# include <unistd.h>
# include <errno.h>
# include <errno.h>
# include <sys/socket.h>
#endif
#endif
// poll vs epoll backend
// poll vs epoll backend
...
@@ -122,6 +123,11 @@ namespace network {
...
@@ -122,6 +123,11 @@ namespace network {
constexpr
int
ec_interrupted_syscall
=
EINTR
;
constexpr
int
ec_interrupted_syscall
=
EINTR
;
#endif
#endif
struct
datagram_endpoint_data
{
sockaddr
addr
;
socklen_t
addrlen
;
};
/**
/**
* @brief Platform-specific native socket type.
* @brief Platform-specific native socket type.
*/
*/
...
...
cppa/system_messages.hpp
View file @
1f9aa431
...
@@ -28,6 +28,9 @@
...
@@ -28,6 +28,9 @@
#include "cppa/accept_handle.hpp"
#include "cppa/accept_handle.hpp"
#include "cppa/connection_handle.hpp"
#include "cppa/connection_handle.hpp"
#include "cppa/io/datagram_endpoint.hpp"
#include "cppa/io/datagram_source_handle.hpp"
#include "cppa/detail/tbind.hpp"
#include "cppa/detail/tbind.hpp"
#include "cppa/detail/type_list.hpp"
#include "cppa/detail/type_list.hpp"
...
@@ -48,7 +51,6 @@ struct exit_msg {
...
@@ -48,7 +51,6 @@ struct exit_msg {
* @brief The exit reason of the terminated actor.
* @brief The exit reason of the terminated actor.
*/
*/
uint32_t
reason
;
uint32_t
reason
;
};
};
/**
/**
...
@@ -63,7 +65,6 @@ struct down_msg {
...
@@ -63,7 +65,6 @@ struct down_msg {
* @brief The exit reason of the terminated actor.
* @brief The exit reason of the terminated actor.
*/
*/
uint32_t
reason
;
uint32_t
reason
;
};
};
/**
/**
...
@@ -78,7 +79,6 @@ struct sync_exited_msg {
...
@@ -78,7 +79,6 @@ struct sync_exited_msg {
* @brief The exit reason of the terminated actor.
* @brief The exit reason of the terminated actor.
*/
*/
uint32_t
reason
;
uint32_t
reason
;
};
};
template
<
typename
T
>
template
<
typename
T
>
...
@@ -107,7 +107,6 @@ struct group_down_msg {
...
@@ -107,7 +107,6 @@ struct group_down_msg {
* @brief The source of this message, i.e., the now unreachable group.
* @brief The source of this message, i.e., the now unreachable group.
*/
*/
group
source
;
group
source
;
};
};
inline
bool
operator
==
(
const
group_down_msg
&
lhs
,
const
group_down_msg
&
rhs
)
{
inline
bool
operator
==
(
const
group_down_msg
&
lhs
,
const
group_down_msg
&
rhs
)
{
...
@@ -124,7 +123,7 @@ inline bool operator!=(const group_down_msg& lhs, const group_down_msg& rhs) {
...
@@ -124,7 +123,7 @@ inline bool operator!=(const group_down_msg& lhs, const group_down_msg& rhs) {
* This system message does not have any fields, because the message ID
* This system message does not have any fields, because the message ID
* sent alongside this message identifies the matching request that timed out.
* sent alongside this message identifies the matching request that timed out.
*/
*/
struct
sync_timeout_msg
{};
struct
sync_timeout_msg
{
};
/**
/**
* @relates exit_msg
* @relates exit_msg
...
@@ -149,7 +148,6 @@ struct timeout_msg {
...
@@ -149,7 +148,6 @@ struct timeout_msg {
* @brief Actor-specific timeout ID.
* @brief Actor-specific timeout ID.
*/
*/
uint32_t
timeout_id
;
uint32_t
timeout_id
;
};
};
inline
bool
operator
==
(
const
timeout_msg
&
lhs
,
const
timeout_msg
&
rhs
)
{
inline
bool
operator
==
(
const
timeout_msg
&
lhs
,
const
timeout_msg
&
rhs
)
{
...
@@ -172,7 +170,6 @@ struct new_connection_msg {
...
@@ -172,7 +170,6 @@ struct new_connection_msg {
* @brief The handle for the new connection.
* @brief The handle for the new connection.
*/
*/
connection_handle
handle
;
connection_handle
handle
;
};
};
inline
bool
operator
==
(
const
new_connection_msg
&
lhs
,
inline
bool
operator
==
(
const
new_connection_msg
&
lhs
,
...
@@ -190,14 +187,13 @@ inline bool operator!=(const new_connection_msg& lhs,
...
@@ -190,14 +187,13 @@ inline bool operator!=(const new_connection_msg& lhs,
*/
*/
struct
new_data_msg
{
struct
new_data_msg
{
/**
/**
* @brief Handle to the related connection
* @brief Handle to the related connection
.
*/
*/
connection_handle
handle
;
connection_handle
handle
;
/**
/**
* @brief Buffer containing the received data.
* @brief Buffer containing the received data.
*/
*/
std
::
vector
<
char
>
buf
;
std
::
vector
<
char
>
buf
;
};
};
inline
bool
operator
==
(
const
new_data_msg
&
lhs
,
const
new_data_msg
&
rhs
)
{
inline
bool
operator
==
(
const
new_data_msg
&
lhs
,
const
new_data_msg
&
rhs
)
{
...
@@ -208,6 +204,24 @@ inline bool operator!=(const new_data_msg& lhs, const new_data_msg& rhs) {
...
@@ -208,6 +204,24 @@ inline bool operator!=(const new_data_msg& lhs, const new_data_msg& rhs) {
return
!
(
lhs
==
rhs
);
return
!
(
lhs
==
rhs
);
}
}
/**
* @brief Signalizes a newly arrived datagram for a {@link broker}.
*/
struct
new_datagram_msg
{
/**
* @brief Handle to the related datagram source.
*/
io
::
datagram_source_handle
handle
;
/**
* @brief Handle to the sender of this datagram.
*/
io
::
datagram_endpoint
endpoint
;
/**
* @brief Buffer containing the received data.
*/
std
::
vector
<
char
>
buf
;
};
/**
/**
* @brief Signalizes that a {@link broker} connection has been closed.
* @brief Signalizes that a {@link broker} connection has been closed.
*/
*/
...
@@ -216,7 +230,6 @@ struct connection_closed_msg {
...
@@ -216,7 +230,6 @@ struct connection_closed_msg {
* @brief Handle to the closed connection.
* @brief Handle to the closed connection.
*/
*/
connection_handle
handle
;
connection_handle
handle
;
};
};
inline
bool
operator
==
(
const
connection_closed_msg
&
lhs
,
inline
bool
operator
==
(
const
connection_closed_msg
&
lhs
,
...
@@ -237,7 +250,6 @@ struct acceptor_closed_msg {
...
@@ -237,7 +250,6 @@ struct acceptor_closed_msg {
* @brief Handle to the closed connection.
* @brief Handle to the closed connection.
*/
*/
accept_handle
handle
;
accept_handle
handle
;
};
};
inline
bool
operator
==
(
const
acceptor_closed_msg
&
lhs
,
inline
bool
operator
==
(
const
acceptor_closed_msg
&
lhs
,
...
...
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