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
e84cb006
Commit
e84cb006
authored
Aug 06, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use binary serialiization for floating points
parent
e19adfa8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
10 deletions
+18
-10
src/binary_deserializer.cpp
src/binary_deserializer.cpp
+4
-1
src/binary_serializer.cpp
src/binary_serializer.cpp
+4
-1
unit_testing/test_remote_actor.cpp
unit_testing/test_remote_actor.cpp
+10
-8
No files found.
src/binary_deserializer.cpp
View file @
e84cb006
...
@@ -70,7 +70,8 @@ inline void range_check(pointer begin, pointer end, size_t read_size) {
...
@@ -70,7 +70,8 @@ inline void range_check(pointer begin, pointer end, size_t read_size) {
template
<
typename
T
>
template
<
typename
T
>
pointer
read_range
(
pointer
begin
,
pointer
end
,
T
&
storage
,
pointer
read_range
(
pointer
begin
,
pointer
end
,
T
&
storage
,
typename
enable_if
<
is_integral
<
T
>::
value
>::
type
*
=
0
)
{
// typename enable_if<is_integral<T>::value>::type* = 0) {
typename
enable_if
<
is_arithmetic
<
T
>::
value
>::
type
*
=
0
)
{
range_check
(
begin
,
end
,
sizeof
(
T
));
range_check
(
begin
,
end
,
sizeof
(
T
));
memcpy
(
&
storage
,
begin
,
sizeof
(
T
));
memcpy
(
&
storage
,
begin
,
sizeof
(
T
));
return
advanced
(
begin
,
sizeof
(
T
));
return
advanced
(
begin
,
sizeof
(
T
));
...
@@ -100,6 +101,7 @@ pointer read_unicode_string(pointer begin, pointer end, StringType& str) {
...
@@ -100,6 +101,7 @@ pointer read_unicode_string(pointer begin, pointer end, StringType& str) {
return
begin
;
return
begin
;
}
}
/*
// @returns the next iterator position
// @returns the next iterator position
template<typename T>
template<typename T>
pointer read_range(pointer begin, pointer end, T& value,
pointer read_range(pointer begin, pointer end, T& value,
...
@@ -111,6 +113,7 @@ pointer read_range(pointer begin, pointer end, T& value,
...
@@ -111,6 +113,7 @@ pointer read_range(pointer begin, pointer end, T& value,
iss >> value;
iss >> value;
return result;
return result;
}
}
*/
pointer
read_range
(
pointer
begin
,
pointer
end
,
u16string
&
storage
)
{
pointer
read_range
(
pointer
begin
,
pointer
end
,
u16string
&
storage
)
{
// char16_t is guaranteed to has *at least* 16 bytes,
// char16_t is guaranteed to has *at least* 16 bytes,
...
...
src/binary_serializer.cpp
View file @
e84cb006
...
@@ -69,10 +69,12 @@ class binary_writer {
...
@@ -69,10 +69,12 @@ class binary_writer {
template
<
typename
T
>
template
<
typename
T
>
void
operator
()(
const
T
&
value
,
void
operator
()(
const
T
&
value
,
typename
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
*
=
0
)
{
// typename enable_if<std::is_integral<T>::value>::type* = 0) {
typename
enable_if
<
std
::
is_arithmetic
<
T
>::
value
>::
type
*
=
0
)
{
write_int
(
m_sink
,
value
);
write_int
(
m_sink
,
value
);
}
}
/*
template<typename T>
template<typename T>
void operator()(const T& value,
void operator()(const T& value,
typename enable_if<std::is_floating_point<T>::value>::type* = 0) {
typename enable_if<std::is_floating_point<T>::value>::type* = 0) {
...
@@ -82,6 +84,7 @@ class binary_writer {
...
@@ -82,6 +84,7 @@ class binary_writer {
iss << value;
iss << value;
(*this)(iss.str());
(*this)(iss.str());
}
}
*/
void
operator
()(
const
std
::
string
&
str
)
{
void
operator
()(
const
std
::
string
&
str
)
{
write_string
(
m_sink
,
str
);
write_string
(
m_sink
,
str
);
...
...
unit_testing/test_remote_actor.cpp
View file @
e84cb006
...
@@ -145,6 +145,8 @@ void await_down(actor_ptr ptr, T continuation) {
...
@@ -145,6 +145,8 @@ void await_down(actor_ptr ptr, T continuation) {
);
);
}
}
static
constexpr
size_t
num_pings
=
10
;
class
client
:
public
event_based_actor
{
class
client
:
public
event_based_actor
{
public:
public:
...
@@ -173,8 +175,8 @@ class client : public event_based_actor {
...
@@ -173,8 +175,8 @@ class client : public event_based_actor {
}
}
void
send_sync_msg
()
{
void
send_sync_msg
()
{
CPPA_PRINT
(
"sync send {'SyncMsg'}"
);
CPPA_PRINT
(
"sync send {'SyncMsg'
, 4.2fSyncMsg
}"
);
sync_send
(
m_server
,
atom
(
"SyncMsg"
)).
then
(
sync_send
(
m_server
,
atom
(
"SyncMsg"
)
,
4.2
f
).
then
(
on
(
atom
(
"SyncReply"
))
>>
[
=
]
{
on
(
atom
(
"SyncReply"
))
>>
[
=
]
{
send_foobars
();
send_foobars
();
}
}
...
@@ -244,11 +246,11 @@ class server : public event_based_actor {
...
@@ -244,11 +246,11 @@ class server : public event_based_actor {
auto
client
=
self
->
last_sender
();
auto
client
=
self
->
last_sender
();
CPPA_LOGF_ERROR_IF
(
!
client
,
"last_sender() == nullptr"
);
CPPA_LOGF_ERROR_IF
(
!
client
,
"last_sender() == nullptr"
);
CPPA_LOGF_INFO
(
"spawn event-based ping actor"
);
CPPA_LOGF_INFO
(
"spawn event-based ping actor"
);
auto
pptr
=
spawn
<
monitored
>
(
event_based_ping
,
10
);
auto
pptr
=
spawn
<
monitored
>
(
event_based_ping
,
num_pings
);
reply
(
atom
(
"PingPtr"
),
pptr
);
reply
(
atom
(
"PingPtr"
),
pptr
);
CPPA_LOGF_INFO
(
"wait until spawned ping actor is done"
);
CPPA_LOGF_INFO
(
"wait until spawned ping actor is done"
);
await_down
(
pptr
,
[
=
]
{
await_down
(
pptr
,
[
=
]
{
CPPA_CHECK_EQUAL
(
pongs
(),
10
);
CPPA_CHECK_EQUAL
(
pongs
(),
num_pings
);
await_sync_msg
();
await_sync_msg
();
});
});
}
}
...
@@ -258,8 +260,9 @@ class server : public event_based_actor {
...
@@ -258,8 +260,9 @@ class server : public event_based_actor {
void
await_sync_msg
()
{
void
await_sync_msg
()
{
CPPA_PRINT
(
"await {'SyncMsg'}"
);
CPPA_PRINT
(
"await {'SyncMsg'}"
);
become
(
become
(
on
(
atom
(
"SyncMsg"
))
>>
[
=
]
{
on
(
atom
(
"SyncMsg"
),
arg_match
)
>>
[
=
](
float
f
)
{
CPPA_PRINT
(
"received {'SyncMsg'}"
);
CPPA_PRINT
(
"received {'SyncMsg', "
<<
f
<<
"}"
);
CPPA_CHECK_EQUAL
(
f
,
4.2
f
);
reply
(
atom
(
"SyncReply"
));
reply
(
atom
(
"SyncReply"
));
await_foobars
();
await_foobars
();
}
}
...
@@ -311,8 +314,7 @@ class server : public event_based_actor {
...
@@ -311,8 +314,7 @@ class server : public event_based_actor {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
announce
<
actor_vector
>
();
announce
<
actor_vector
>
();
add_tuple_hint
<
atom_value
>
();
add_tuple_hint
<
atom_value
,
int
>
();
add_tuple_hint
<
atom_value
,
actor_ptr
>
();
add_tuple_hint
<
atom_value
,
atom_value
,
int
>
();
add_tuple_hint
<
atom_value
,
atom_value
,
int
>
();
string
app_path
=
argv
[
0
];
string
app_path
=
argv
[
0
];
bool
run_remote_actor
=
true
;
bool
run_remote_actor
=
true
;
...
...
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