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
55f8bee0
Commit
55f8bee0
authored
Aug 09, 2018
by
Matthias Vallentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make pubsync() reset the get area
parent
8933b78f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
libcaf_core/caf/streambuf.hpp
libcaf_core/caf/streambuf.hpp
+11
-1
libcaf_core/test/streambuf.cpp
libcaf_core/test/streambuf.cpp
+5
-0
No files found.
libcaf_core/caf/streambuf.hpp
View file @
55f8bee0
...
@@ -268,7 +268,8 @@ public:
...
@@ -268,7 +268,8 @@ public:
// We use a const_cast because C++11 doesn't provide a non-const data()
// We use a const_cast because C++11 doesn't provide a non-const data()
// overload. Using std::data(c) would be the right way to write this.
// overload. Using std::data(c) would be the right way to write this.
auto
data
=
const_cast
<
char_type
*>
(
c
.
data
());
auto
data
=
const_cast
<
char_type
*>
(
c
.
data
());
setbuf
(
data
,
static_cast
<
std
::
streamsize
>
(
c
.
size
()));
auto
size
=
static_cast
<
std
::
streamsize
>
(
c
.
size
());
setbuf
(
data
,
size
);
}
}
// See note in arraybuf(arraybuf&&).
// See note in arraybuf(arraybuf&&).
...
@@ -331,6 +332,15 @@ protected:
...
@@ -331,6 +332,15 @@ protected:
return
this
->
default_seekoff
(
off
,
dir
,
which
);
return
this
->
default_seekoff
(
off
,
dir
,
which
);
}
}
// Synchronizes the get area with the underlying buffer.
int
sync
()
override
{
// See note in ctor for const_cast
auto
data
=
const_cast
<
char_type
*>
(
container_
.
data
());
auto
size
=
static_cast
<
std
::
streamsize
>
(
container_
.
size
());
setbuf
(
data
,
size
);
return
0
;
}
// -- get area -------------------------------------------------------------
// -- get area -------------------------------------------------------------
// We can't get obtain more characters on underflow, so we only optimize
// We can't get obtain more characters on underflow, so we only optimize
...
...
libcaf_core/test/streambuf.cpp
View file @
55f8bee0
...
@@ -141,4 +141,9 @@ CAF_TEST(containerbuf_reset_get_area) {
...
@@ -141,4 +141,9 @@ CAF_TEST(containerbuf_reset_get_area) {
n
=
vb
.
sgetn
(
bar
,
3
);
n
=
vb
.
sgetn
(
bar
,
3
);
CAF_CHECK_EQUAL
(
n
,
3
);
CAF_CHECK_EQUAL
(
n
,
3
);
CAF_CHECK_EQUAL
(
std
::
string
(
bar
,
3
),
"bar"
);
CAF_CHECK_EQUAL
(
std
::
string
(
bar
,
3
),
"bar"
);
// Synchronize the get area after having messed with the underlying buffer.
buf
.
resize
(
1
);
CAF_CHECK_EQUAL
(
vb
.
pubsync
(),
0
);
CAF_CHECK_EQUAL
(
vb
.
sbumpc
(),
'f'
);
CAF_CHECK_EQUAL
(
vb
.
in_avail
(),
0
);
}
}
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