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
c9437270
Commit
c9437270
authored
May 05, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimized outgoing messaging
parent
d1f86cf2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
19 deletions
+21
-19
cppa/binary_serializer.hpp
cppa/binary_serializer.hpp
+4
-6
src/binary_serializer.cpp
src/binary_serializer.cpp
+15
-9
src/mailman.cpp
src/mailman.cpp
+2
-4
No files found.
cppa/binary_serializer.hpp
View file @
c9437270
...
@@ -72,12 +72,6 @@ class binary_serializer : public serializer
...
@@ -72,12 +72,6 @@ class binary_serializer : public serializer
void
write_tuple
(
size_t
size
,
primitive_variant
const
*
values
);
void
write_tuple
(
size_t
size
,
primitive_variant
const
*
values
);
/**
* @brief Takes the internal buffer and returns it.
*
*/
std
::
pair
<
size_t
,
char
*>
take_buffer
();
/**
/**
* @brief Returns the number of written bytes.
* @brief Returns the number of written bytes.
*/
*/
...
@@ -88,6 +82,10 @@ class binary_serializer : public serializer
...
@@ -88,6 +82,10 @@ class binary_serializer : public serializer
*/
*/
char
const
*
data
()
const
;
char
const
*
data
()
const
;
size_t
sendable_size
()
const
;
char
const
*
sendable_data
();
/**
/**
* @brief Resets the internal buffer.
* @brief Resets the internal buffer.
*/
*/
...
...
src/binary_serializer.cpp
View file @
c9437270
...
@@ -41,6 +41,7 @@ using std::enable_if;
...
@@ -41,6 +41,7 @@ using std::enable_if;
namespace
{
namespace
{
constexpr
size_t
chunk_size
=
512
;
constexpr
size_t
chunk_size
=
512
;
constepxr
size_t
ui32_size
=
sizeof
(
std
::
uint32_t
);
}
// namespace <anonymous>
}
// namespace <anonymous>
...
@@ -133,6 +134,7 @@ void binary_serializer::acquire(size_t num_bytes)
...
@@ -133,6 +134,7 @@ void binary_serializer::acquire(size_t num_bytes)
{
{
if
(
!
m_begin
)
if
(
!
m_begin
)
{
{
num_bytes
+=
ui32_size
;
size_t
new_size
=
chunk_size
;
size_t
new_size
=
chunk_size
;
while
(
new_size
<=
num_bytes
)
while
(
new_size
<=
num_bytes
)
{
{
...
@@ -140,7 +142,7 @@ void binary_serializer::acquire(size_t num_bytes)
...
@@ -140,7 +142,7 @@ void binary_serializer::acquire(size_t num_bytes)
}
}
m_begin
=
new
char
[
new_size
];
m_begin
=
new
char
[
new_size
];
m_end
=
m_begin
+
new_size
;
m_end
=
m_begin
+
new_size
;
m_wr_pos
=
m_begin
;
m_wr_pos
=
m_begin
+
ui32_size
;
}
}
else
else
{
{
...
@@ -203,22 +205,26 @@ void binary_serializer::write_tuple(size_t size,
...
@@ -203,22 +205,26 @@ void binary_serializer::write_tuple(size_t size,
}
}
}
}
s
td
::
pair
<
size_t
,
char
*>
binary_serializer
::
take_buffer
()
s
ize_t
binary_serializer
::
sendable_size
()
const
{
{
char
*
begin
=
m_begin
;
return
static_cast
<
size_t
>
(
m_wr_pos
-
m_begin
);
char
*
end
=
m_end
;
m_begin
=
m_end
=
m_wr_pos
=
nullptr
;
return
{
static_cast
<
size_t
>
(
end
-
begin
),
begin
};
}
}
size_t
binary_serializer
::
size
()
const
size_t
binary_serializer
::
size
()
const
{
{
return
static_cast
<
size_t
>
(
m_wr_pos
-
m_begin
);
return
sendable_size
()
-
ui32_size
;
}
char
const
*
binary_serializer
::
data
()
const
{
return
m_begin
+
ui32_size
;
}
}
c
onst
char
*
binary_serializer
::
data
()
const
c
har
const
*
binary_serializer
::
sendable_data
()
{
{
return
m_begin
;
auto
s
=
static_cast
<
std
::
uint32_t
>
(
size
());
memcpy
(
m_begin
,
&
s
,
ui32_size
);
return
m_begin
();
}
}
void
binary_serializer
::
reset
()
void
binary_serializer
::
reset
()
...
...
src/mailman.cpp
View file @
c9437270
...
@@ -73,10 +73,8 @@ void mailman_loop()
...
@@ -73,10 +73,8 @@ void mailman_loop()
bs
<<
msg
;
bs
<<
msg
;
auto
size32
=
static_cast
<
std
::
uint32_t
>
(
bs
.
size
());
auto
size32
=
static_cast
<
std
::
uint32_t
>
(
bs
.
size
());
DEBUG
(
"--> "
<<
to_string
(
msg
));
DEBUG
(
"--> "
<<
to_string
(
msg
));
// write size of serialized message
auto
sent
=
::
send
(
peer_fd
,
bs
.
sendable_data
(),
bs
.
sendable_size
());
auto
sent
=
::
send
(
peer_fd
,
&
size32
,
sizeof
(
std
::
uint32_t
),
0
);
if
(
sent
!=
bs
.
sendable_size
())
if
(
sent
!=
static_cast
<
int
>
(
sizeof
(
std
::
uint32_t
))
||
static_cast
<
int
>
(
bs
.
size
())
!=
::
send
(
peer_fd
,
bs
.
data
(),
bs
.
size
(),
0
))
{
{
disconnect_peer
=
true
;
disconnect_peer
=
true
;
DEBUG
(
"too few bytes written"
);
DEBUG
(
"too few bytes written"
);
...
...
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