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
d4020bfe
Commit
d4020bfe
authored
Nov 10, 2016
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP Unifies datagram sink and source in endpoint
parent
2690ac42
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
258 additions
and
0 deletions
+258
-0
libcaf_io/caf/io/abstract_broker.hpp
libcaf_io/caf/io/abstract_broker.hpp
+6
-0
libcaf_io/caf/io/endpoint.hpp
libcaf_io/caf/io/endpoint.hpp
+75
-0
libcaf_io/caf/io/endpoint_handle.hpp
libcaf_io/caf/io/endpoint_handle.hpp
+84
-0
libcaf_io/caf/io/network/endpoint_manager.hpp
libcaf_io/caf/io/network/endpoint_manager.hpp
+50
-0
libcaf_io/caf/io/system_messages.hpp
libcaf_io/caf/io/system_messages.hpp
+1
-0
libcaf_io/src/endpoint.cpp
libcaf_io/src/endpoint.cpp
+42
-0
libcaf_io/src/endpoint_handle.cpp
libcaf_io/src/endpoint_handle.cpp
+0
-0
libcaf_io/src/endpoint_manager.cpp
libcaf_io/src/endpoint_manager.cpp
+0
-0
No files found.
libcaf_io/caf/io/abstract_broker.hpp
View file @
d4020bfe
...
...
@@ -30,6 +30,7 @@
#include "caf/io/fwd.hpp"
#include "caf/io/accept_handle.hpp"
#include "caf/io/receive_policy.hpp"
#include "caf/io/endpoint_handle.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/connection_handle.hpp"
#include "caf/io/datagram_sink_handle.hpp"
...
...
@@ -38,6 +39,7 @@
#include "caf/io/network/native_socket.hpp"
#include "caf/io/network/stream_manager.hpp"
#include "caf/io/network/acceptor_manager.hpp"
#include "caf/io/network/endpoint_manager.hpp"
#include "caf/io/network/datagram_sink_manager.hpp"
#include "caf/io/network/datagram_source_manager.hpp"
...
...
@@ -86,6 +88,7 @@ public:
// even brokers need friends
friend
class
scribe
;
friend
class
doorman
;
friend
class
endpoint
;
friend
class
datagram_sink
;
friend
class
datagram_source
;
...
...
@@ -340,6 +343,9 @@ protected:
using
datagram_source_map
=
std
::
unordered_map
<
datagram_source_handle
,
intrusive_ptr
<
datagram_source
>>
;
using
endpoint_map
=
std
::
unordered_map
<
endpoint_handle
,
intrusive_ptr
<
endpoint
>>
;
/// @cond PRIVATE
// meta programming utility
...
...
libcaf_io/caf/io/endpoint.hpp
0 → 100644
View file @
d4020bfe
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_ENDPOINT_HPP
#define CAF_IO_ENDPOINT_HPP
#include "caf/message.hpp"
#include "caf/io/broker_servant.hpp"
#include "caf/io/endpoint_handle.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/network/endpoint_manager.hpp"
namespace
caf
{
namespace
io
{
using
endpoint_base
=
broker_servant
<
network
::
endpoint_manager
,
endpoint_handle
,
datagram_sent_msg
>
;
/// Manages writing and reading on a datagram endpoint.
/// @ingroup Broker
class
endpoint
:
public
endpoint_base
{
public:
endpoint
(
abstract_broker
*
parent
,
datagram_sink_handle
hdl
);
~
endpoint
();
/// Enables or disables write notifications.
virtual
void
ack_writes
(
bool
enable
)
=
0
;
/// Configure buffer size for next accepted datagram.
virtual
void
configure_datagram_size
(
size_t
buf_size
)
=
0
;
/// Returns the current write buffer.
virtual
std
::
vector
<
char
>&
wr_buf
()
=
0
;
/// Returns the current input buffer.
virtual
std
::
vector
<
char
>&
rd_buf
()
=
0
;
bool
consume
(
execution_unit
*
ctx
,
const
void
*
buf
,
size_t
besize
)
override
;
void
datagram_sent
(
execution_unit
*
ctx
,
size_t
num_bytes
)
override
;
void
io_failure
(
execution_unit
*
ctx
,
network
::
operation
op
)
override
;
// needs to be launched explicitly, TODO: Does it?
// Can't configure_datagram_size do that?
virtual
void
launch
()
=
0
;
protected:
message
detach_message
()
override
;
};
}
// namespace io
}
// namespace caf
#endif // CAF_IO_ENDPOINT_HPP
libcaf_io/caf/io/endpoint_handle.hpp
0 → 100644
View file @
d4020bfe
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_ENDPOINT_HANDLE_HPP
#define CAF_IO_ENDPOINT_HANDLE_HPP
#include "caf/error.hpp"
#include "caf/io/handle.hpp"
#include "caf/meta/type_name.hpp"
namespace
caf
{
namespace
io
{
struct
invalid_endpoint_handle_t
{
constexpr
invalid_endpoint_handle_t
()
{
// nop
}
};
constexpr
invalid_endpoint_handle_t
invalid_endpoint_handle
=
invalid_endpoint_handle_t
{};
/// Generic handle type for managing local and remote datagram endpoints.
class
endpoint_handle
:
public
handle
<
endpoint_handle
,
invalid_endpoint_handle_t
>
{
public:
friend
class
handle
<
endpoint_handle
,
invalid_endpoint_handle_t
>
;
using
super
=
handle
<
endpoint_handle
,
invalid_endpoint_handle_t
>
;
constexpr
endpoint_handle
()
{
// nop
}
constexpr
endpoint_handle
(
const
invalid_endpoint_handle_t
&
)
{
// nop
}
template
<
class
Inspector
>
friend
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
endpoint_handle
&
x
)
{
return
f
(
meta
::
type_name
(
"endpoint_handle"
),
x
.
id_
);
}
private:
inline
endpoint_handle
(
int64_t
handle_id
)
:
super
(
handle_id
)
{
// nop
}
};
}
// namespace ios
}
// namespace caf
namespace
std
{
template
<
>
struct
hash
<
caf
::
io
::
endpoint_handle
>
{
size_t
operator
()(
const
caf
::
io
::
endpoint_handle
&
hdl
)
const
{
hash
<
int64_t
>
f
;
return
f
(
hdl
.
id
());
}
};
}
// namespace std
#endif // CAF_IO_ENDPOINT_HANDLE_HPP
libcaf_io/caf/io/network/endpoint_manager.hpp
0 → 100644
View file @
d4020bfe
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_NETWORK_ENDPOINT_MANAGER_HPP
#define CAF_IO_NETWORK_ENDPOINT_MANAGER_HPP
#include "caf/io/network/manager.hpp"
namespace
caf
{
namespace
io
{
namespace
network
{
/// An endpoint manager configures datagram endpoints and provides callbacks
/// for incoming data as well as for error handling.
class
endpoint_manager
:
public
manager
{
public:
endpoint_manager
(
abstract_broker
*
ptr
);
~
endpoint_manager
();
/// Called by the underlying I/O device whenever it received data.
/// @returns `true` if the manager accepts further reads, otherwise `false`.
virtual
bool
consume
(
execution_unit
*
ctx
,
const
void
*
buf
,
size_t
bsize
)
=
0
;
/// Called by the underlying I/O device whenever it sent a datagram.
virtual
void
datagram_sent
(
execution_unit
*
ctx
,
size_t
num_bytes
)
=
0
;
};
}
// namespace network
}
// namespace io
}
// namespace caf
#endif // CAF_IO_NETWORK_ENDPOINT_MANAGER_HPP
libcaf_io/caf/io/system_messages.hpp
View file @
d4020bfe
...
...
@@ -29,6 +29,7 @@
#include "caf/io/handle.hpp"
#include "caf/io/accept_handle.hpp"
#include "caf/io/endpoint_handle.hpp"
#include "caf/io/connection_handle.hpp"
#include "caf/io/datagram_sink_handle.hpp"
#include "caf/io/datagram_source_handle.hpp"
...
...
libcaf_io/src/endpoint.cpp
0 → 100644
View file @
d4020bfe
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/io/endpoint.hpp"
#include "caf/logger.hpp"
namespace
caf
{
namespace
io
{
endpoint
::
endpoint
(
abstract_broker
*
parent
,
datagram_sink_handle
hdl
)
:
endpoint_base
(
parent
,
hdl
)
{
// nop
}
endpoint
::~
endpoint
()
{
CAF_LOG_TRACE
(
""
);
}
message
endpoint
::
detach_message
()
{
return
make_message
(
endpoint_closed_msg
{
hdl
()});
}
}
// namespace io
}
// namespace caf
libcaf_io/src/endpoint_handle.cpp
0 → 100644
View file @
d4020bfe
libcaf_io/src/endpoint_manager.cpp
0 → 100644
View file @
d4020bfe
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