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
e0e0012e
Commit
e0e0012e
authored
Aug 01, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split up newb test file
parent
7673ab3f
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1891 additions
and
2047 deletions
+1891
-2047
examples/CMakeLists.txt
examples/CMakeLists.txt
+2
-1
examples/remoting/newbc.cpp
examples/remoting/newbc.cpp
+0
-63
examples/remoting/tcp_newb.cpp
examples/remoting/tcp_newb.cpp
+671
-0
examples/remoting/udp_newb.cpp
examples/remoting/udp_newb.cpp
+751
-0
libcaf_io/caf/io/network/newb.hpp
libcaf_io/caf/io/network/newb.hpp
+368
-94
libcaf_io/test/protocol_policy.cpp
libcaf_io/test/protocol_policy.cpp
+99
-1889
No files found.
examples/CMakeLists.txt
View file @
e0e0012e
...
...
@@ -51,7 +51,8 @@ add(remoting group_chat)
add
(
remoting group_server
)
add
(
remoting remote_spawn
)
add
(
remoting distributed_calculator
)
add
(
remoting newbc
)
add
(
remoting udp_newb
)
add
(
remoting tcp_newb
)
# basic I/O with brokers
add
(
broker simple_broker
)
...
...
examples/remoting/newbc.cpp
deleted
100644 → 0
View file @
7673ab3f
#include <mutex>
#include <thread>
#include <iostream>
#include <condition_variable>
#include "caf/all.hpp"
#include "caf/io/all.hpp"
#include "caf/io/network/newb.hpp"
#include "caf/io/network/default_multiplexer.hpp"
using
namespace
caf
;
using
namespace
caf
::
io
::
network
;
namespace
{
class
config
:
public
actor_system_config
{
public:
uint16_t
port
=
0
;
std
::
string
host
=
"localhost"
;
bool
server_mode
=
false
;
config
()
{
opt_group
{
custom_options_
,
"global"
}
.
add
(
port
,
"port,p"
,
"set port"
)
.
add
(
host
,
"host,H"
,
"set host (ignored in server mode)"
)
.
add
(
server_mode
,
"server-mode,s"
,
"enable server mode"
);
}
};
void
caf_main
(
actor_system
&
system
,
const
config
&
)
{
default_multiplexer
mpx
{
&
system
};
// Setup thread to run the multiplexer.
std
::
thread
t
;
std
::
atomic
<
bool
>
init_done
{
false
};
std
::
mutex
mtx
;
std
::
condition_variable
cv
;
t
=
std
::
thread
{[
&
]
{
system
.
thread_started
();
std
::
cout
<<
"starting multiplexer"
<<
std
::
endl
;
{
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx
};
mpx
.
thread_id
(
std
::
this_thread
::
get_id
());
init_done
=
true
;
cv
.
notify_one
();
}
mpx
.
run
();
system
.
thread_terminates
();
}};
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx
};
while
(
init_done
==
false
)
cv
.
wait
(
guard
);
// Create an event handling actor to run in the multiplexer.
actor_config
cfg
{
&
mpx
};
auto
n
=
make_newb
<
detail
::
protocol_policy
,
detail
::
mutating_policy
>
(
system
,
cfg
,
mpx
,
-
1
);
anon_send
(
n
,
1
);
t
.
join
();
}
}
// namespace <anonymous>
CAF_MAIN
(
io
::
middleman
)
examples/remoting/tcp_newb.cpp
0 → 100644
View file @
e0e0012e
This diff is collapsed.
Click to expand it.
examples/remoting/udp_newb.cpp
0 → 100644
View file @
e0e0012e
This diff is collapsed.
Click to expand it.
libcaf_io/caf/io/network/newb.hpp
View file @
e0e0012e
This diff is collapsed.
Click to expand it.
libcaf_io/test/protocol_policy.cpp
View file @
e0e0012e
This diff is collapsed.
Click to expand it.
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