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
92d54efe
Commit
92d54efe
authored
Aug 03, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change scribe/scribe-test to match new application-policy api
parent
f2220260
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
29 deletions
+27
-29
libcaf_net/CMakeLists.txt
libcaf_net/CMakeLists.txt
+1
-1
libcaf_net/caf/policy/scribe.hpp
libcaf_net/caf/policy/scribe.hpp
+5
-15
libcaf_net/src/scribe.cpp
libcaf_net/src/scribe.cpp
+13
-3
libcaf_net/test/scribe.cpp
libcaf_net/test/scribe.cpp
+8
-10
No files found.
libcaf_net/CMakeLists.txt
View file @
92d54efe
...
@@ -18,7 +18,7 @@ set(LIBCAF_NET_SRCS
...
@@ -18,7 +18,7 @@ set(LIBCAF_NET_SRCS
src/socket.cpp
src/socket.cpp
src/socket_manager.cpp
src/socket_manager.cpp
src/stream_socket.cpp
src/stream_socket.cpp
src/scribe.cpp
src/scribe.cpp
)
)
add_custom_target
(
libcaf_net
)
add_custom_target
(
libcaf_net
)
...
...
libcaf_net/caf/policy/scribe.hpp
View file @
92d54efe
...
@@ -25,16 +25,15 @@
...
@@ -25,16 +25,15 @@
#include <caf/net/receive_policy.hpp>
#include <caf/net/receive_policy.hpp>
#include <caf/net/stream_socket.hpp>
#include <caf/net/stream_socket.hpp>
#include <caf/sec.hpp>
#include <caf/sec.hpp>
#include <caf/span.hpp>
#include <caf/variant.hpp>
#include <caf/variant.hpp>
#ifdef CAF_WINDOWS
#ifdef CAF_WINDOWS
# include <winsock2.h>
# include <winsock2.h>
#else
#else
# include <caf/actor.hpp>
# include <caf/actor.hpp>
# include <sys/socket.h>
# include <sys/socket.h>
# include <sys/types.h>
# include <sys/types.h>
#endif
#endif
namespace
caf
{
namespace
caf
{
...
@@ -42,16 +41,7 @@ namespace policy {
...
@@ -42,16 +41,7 @@ namespace policy {
class
scribe
{
class
scribe
{
public:
public:
explicit
scribe
(
net
::
stream_socket
handle
)
explicit
scribe
(
net
::
stream_socket
handle
);
:
handle_
(
handle
),
max_consecutive_reads_
(
0
),
read_threshold_
(
1024
),
collected_
(
0
),
max_
(
1024
),
rd_flag_
(
net
::
receive_policy_flag
::
exactly
),
written_
(
0
)
{
// nop
}
net
::
stream_socket
handle_
;
net
::
stream_socket
handle_
;
...
@@ -76,7 +66,7 @@ public:
...
@@ -76,7 +66,7 @@ public:
CAF_LOG_DEBUG
(
CAF_ARG
(
len
)
<<
CAF_ARG
(
handle_
.
id
)
<<
CAF_ARG
(
*
num_bytes
));
CAF_LOG_DEBUG
(
CAF_ARG
(
len
)
<<
CAF_ARG
(
handle_
.
id
)
<<
CAF_ARG
(
*
num_bytes
));
collected_
+=
*
num_bytes
;
collected_
+=
*
num_bytes
;
if
(
collected_
>=
read_threshold_
)
{
if
(
collected_
>=
read_threshold_
)
{
parent
.
application
().
process
(
read_buf_
,
*
this
,
parent
);
parent
.
application
().
handle_data
(
*
this
,
read_buf_
);
prepare_next_read
();
prepare_next_read
();
return
false
;
return
false
;
}
else
{
}
else
{
...
@@ -98,7 +88,7 @@ public:
...
@@ -98,7 +88,7 @@ public:
// get new data from parent
// get new data from parent
for
(
auto
msg
=
parent
.
next_message
();
msg
!=
nullptr
;
for
(
auto
msg
=
parent
.
next_message
();
msg
!=
nullptr
;
msg
=
parent
.
next_message
())
{
msg
=
parent
.
next_message
())
{
parent
.
application
().
prepare
(
std
::
move
(
msg
),
*
this
);
parent
.
application
().
write_message
(
*
this
,
std
::
move
(
msg
)
);
}
}
// write prepared data
// write prepared data
return
write_some
(
parent
);
return
write_some
(
parent
);
...
@@ -151,7 +141,7 @@ public:
...
@@ -151,7 +141,7 @@ public:
void
configure_read
(
net
::
receive_policy
::
config
cfg
);
void
configure_read
(
net
::
receive_policy
::
config
cfg
);
std
::
vector
<
char
>&
wr_buf
(
);
void
write_packet
(
span
<
char
>
buf
);
private:
private:
std
::
vector
<
char
>
read_buf_
;
std
::
vector
<
char
>
read_buf_
;
...
...
libcaf_net/src/scribe.cpp
View file @
92d54efe
...
@@ -21,11 +21,21 @@
...
@@ -21,11 +21,21 @@
#include <system_error>
#include <system_error>
#include "caf/config.hpp"
#include "caf/config.hpp"
#include "caf/variant.hpp"
namespace
caf
{
namespace
caf
{
namespace
policy
{
namespace
policy
{
scribe
::
scribe
(
caf
::
net
::
stream_socket
handle
)
:
handle_
(
handle
),
max_consecutive_reads_
(
0
),
read_threshold_
(
1024
),
collected_
(
0
),
max_
(
1024
),
rd_flag_
(
net
::
receive_policy_flag
::
exactly
),
written_
(
0
)
{
// nop
}
void
scribe
::
prepare_next_read
()
{
void
scribe
::
prepare_next_read
()
{
collected_
=
0
;
collected_
=
0
;
// This cast does nothing, but prevents a weird compiler error on GCC <= 4.9.
// This cast does nothing, but prevents a weird compiler error on GCC <= 4.9.
...
@@ -58,8 +68,8 @@ void scribe::configure_read(net::receive_policy::config cfg) {
...
@@ -58,8 +68,8 @@ void scribe::configure_read(net::receive_policy::config cfg) {
prepare_next_read
();
prepare_next_read
();
}
}
std
::
vector
<
char
>&
scribe
::
wr_buf
(
)
{
void
scribe
::
write_packet
(
span
<
char
>
buf
)
{
return
write_buf_
;
write_buf_
.
insert
(
write_buf_
.
end
(),
buf
.
begin
(),
buf
.
end
())
;
}
}
}
// namespace policy
}
// namespace policy
...
...
libcaf_net/test/scribe.cpp
View file @
92d54efe
...
@@ -67,24 +67,22 @@ public:
...
@@ -67,24 +67,22 @@ public:
~
dummy_application
()
=
default
;
~
dummy_application
()
=
default
;
template
<
class
Transport
>
template
<
class
Transport
>
void
prepare
(
std
::
unique_ptr
<
endpoint_manager
::
message
>
msg
,
void
write_message
(
Transport
&
transport
,
Transport
&
transport
)
{
std
::
unique_ptr
<
endpoint_manager
::
message
>
msg
)
{
auto
&
buf
=
transport
.
wr_buf
();
transport
.
write_packet
(
msg
->
payload
);
auto
&
msg_buf
=
msg
->
payload
;
buf
.
resize
(
msg_buf
.
size
());
buf
.
insert
(
buf
.
begin
(),
msg_buf
.
begin
(),
msg_buf
.
end
());
}
}
template
<
class
Transpor
t
>
template
<
class
Paren
t
>
void
process
(
std
::
vector
<
char
>
payload
,
Transport
&
,
socket_manager
&
)
{
void
handle_data
(
Parent
&
,
span
<
char
>
data
)
{
rec_buf_
->
clear
();
rec_buf_
->
clear
();
rec_buf_
->
insert
(
rec_buf_
->
begin
(),
payload
.
begin
(),
payload
.
end
());
rec_buf_
->
insert
(
rec_buf_
->
begin
(),
data
.
begin
(),
data
.
end
());
}
}
template
<
class
Manager
>
template
<
class
Manager
>
void
resolve
(
Manager
&
manager
,
const
std
::
string
&
path
,
actor
listener
)
{
void
resolve
(
Manager
&
manager
,
const
std
::
string
&
path
,
actor
listener
)
{
actor_id
aid
=
42
;
actor_id
aid
=
42
;
node_id
nid
{
42
,
"00112233445566778899aa00112233445566778899aa"
};
auto
hid
=
"0011223344556677889900112233445566778899"
;
auto
nid
=
unbox
(
make_node_id
(
42
,
hid
));
actor_config
cfg
;
actor_config
cfg
;
auto
p
=
make_actor
<
actor_proxy_impl
,
strong_actor_ptr
>
(
aid
,
nid
,
auto
p
=
make_actor
<
actor_proxy_impl
,
strong_actor_ptr
>
(
aid
,
nid
,
&
manager
.
system
(),
&
manager
.
system
(),
...
...
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