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
23cf2b9c
Commit
23cf2b9c
authored
Aug 28, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add transport_worker
parent
e23a402f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
libcaf_net/caf/net/transport_worker.hpp
libcaf_net/caf/net/transport_worker.hpp
+99
-0
No files found.
libcaf_net/caf/net/transport_worker.hpp
0 → 100644
View file @
23cf2b9c
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* 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. *
******************************************************************************/
#pragma once
#include "caf/byte.hpp"
#include "caf/ip_endpoint.hpp"
#include "caf/net/endpoint_manager.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/write_packet_decorator.hpp"
#include "caf/span.hpp"
#include "caf/unit.hpp"
namespace
caf
{
namespace
net
{
/// implements a worker for the udp_transport policy
template
<
class
Application
,
class
IdType
=
unit_t
>
class
transport_worker
{
public:
// -- member types -----------------------------------------------------------
using
id_type
=
IdType
;
using
application_type
=
Application
;
// -- constructors, destructors, and assignment operators --------------------
transport_worker
(
application_type
application
,
id_type
id
=
id_type
{})
:
application_
(
std
::
move
(
application
)),
id_
(
std
::
move
(
id
))
{
// nop
}
// -- member functions -------------------------------------------------------
template
<
class
Parent
>
error
init
(
Parent
&
parent
)
{
auto
decorator
=
make_write_packet_decorator
(
*
this
,
parent
);
application_
.
init
(
decorator
);
return
none
;
}
template
<
class
Parent
>
void
handle_data
(
Parent
&
parent
,
span
<
byte
>
data
)
{
application_
.
handle_data
(
parent
,
data
);
}
template
<
class
Parent
>
void
write_message
(
Parent
&
parent
,
std
::
unique_ptr
<
net
::
endpoint_manager
::
message
>
msg
)
{
auto
decorator
=
make_write_packet_decorator
(
*
this
,
parent
);
application_
.
write_message
(
decorator
,
std
::
move
(
msg
));
}
template
<
class
Parent
>
void
write_packet
(
Parent
&
parent
,
span
<
const
byte
>
header
,
span
<
const
byte
>
payload
)
{
parent
.
write_packet
(
header
,
payload
,
id_
);
}
template
<
class
Parent
>
void
resolve
(
Parent
&
parent
,
const
std
::
string
&
path
,
actor
listener
)
{
application_
.
resolve
(
parent
,
path
,
listener
);
}
template
<
class
Parent
>
void
timeout
(
Parent
&
parent
,
atom_value
value
,
uint64_t
id
)
{
application_
.
timeout
(
parent
,
value
,
id
);
}
void
handle_error
(
sec
error
)
{
application_
.
handle_error
(
error
);
}
private:
application_type
application_
;
id_type
id_
;
};
template
<
class
Application
>
using
transport_worker_ptr
=
std
::
shared_ptr
<
transport_worker
<
Application
>>
;
}
// namespace net
}
// namespace caf
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