Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ReadMailReallyFast
code
Commits
cfbce152
Commit
cfbce152
authored
2 years ago
by
Benny Baumann
Browse files
Options
Downloads
Patches
Plain Diff
chg: ioqueue interface changes
parent
28206ae2
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
First unit tests
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/net/ioqueue.cpp
+0
-46
0 additions, 46 deletions
src/net/ioqueue.cpp
src/net/ioqueue.hpp
+43
-9
43 additions, 9 deletions
src/net/ioqueue.hpp
src/net/tcp_client.hpp
+1
-1
1 addition, 1 deletion
src/net/tcp_client.hpp
with
44 additions
and
56 deletions
src/net/ioqueue.cpp
+
0
−
46
View file @
cfbce152
...
...
@@ -41,50 +41,4 @@ void iorecord::advance(size_t amount) {
this
->
offset
+=
std
::
min
(
amount
,
this
->
size
());
}
ioqueue
::
ioqueue
()
:
queue
{}
{
// NOP
}
ioqueue
::~
ioqueue
()
{
// NOP
}
bool
ioqueue
::
empty
()
const
{
return
this
->
queue
.
empty
();
}
void
ioqueue
::
push_back
(
const
iorecord
&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
push_back
(
data
);
}
}
void
ioqueue
::
push_back
(
iorecord
&&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
emplace_back
(
std
::
forward
<
iorecord
>
(
data
));
}
}
void
ioqueue
::
push_front
(
const
iorecord
&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
push_front
(
data
);
}
}
void
ioqueue
::
push_front
(
iorecord
&&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
emplace_front
(
std
::
forward
<
iorecord
>
(
data
));
}
}
iorecord
ioqueue
::
pop_front
()
{
if
(
this
->
empty
())
{
return
iorecord
{};
}
iorecord
result
=
this
->
queue
.
front
();
this
->
queue
.
pop_front
();
return
result
;
}
}
// namespace rmrf::net
This diff is collapsed.
Click to expand it.
src/net/ioqueue.hpp
+
43
−
9
View file @
cfbce152
...
...
@@ -27,23 +27,57 @@ namespace rmrf::net {
void
advance
(
size_t
amount
);
};
template
<
class
iorecord_type
=
iorecord
>
class
ioqueue
{
private:
std
::
deque
<
iorecord
>
queue
;
std
::
deque
<
iorecord
_type
>
queue
;
public:
ioqueue
();
~
ioqueue
();
static_assert
(
std
::
is_base_of
<
iorecord
,
iorecord_type
>::
value
,
"Your iorecord implementation needs to be a subclass of iorecord."
);
ioqueue
()
:
queue
{}
{
// NOP
}
bool
empty
()
const
;
~
ioqueue
()
{
// NOP
}
bool
empty
()
const
{
return
this
->
queue
.
empty
();
}
void
push_back
(
const
iorecord_type
&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
push_back
(
data
);
}
}
void
push_back
(
iorecord_type
&&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
emplace_back
(
std
::
forward
<
iorecord_type
>
(
data
));
}
}
void
push_front
(
const
iorecord_type
&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
push_front
(
data
);
}
}
void
push_back
(
const
iorecord
&
data
);
void
push_back
(
iorecord
&&
data
);
void
push_front
(
iorecord_type
&&
data
)
{
if
(
!
data
.
empty
())
{
this
->
queue
.
emplace_front
(
std
::
forward
<
iorecord_type
>
(
data
));
}
}
void
push_front
(
const
iorecord
&
data
);
void
push_front
(
iorecord
&&
data
);
iorecord_type
pop_front
()
{
if
(
this
->
empty
())
{
return
iorecord_type
{};
}
iorecord
pop_front
();
auto
result
=
this
->
queue
.
front
();
this
->
queue
.
pop_front
();
return
result
;
}
};
}
This diff is collapsed.
Click to expand it.
src/net/tcp_client.hpp
+
1
−
1
View file @
cfbce152
...
...
@@ -46,7 +46,7 @@ private:
uint16_t
port
;
auto_fd
net_socket
;
::
ev
::
io
io
;
ioqueue
write_queue
;
ioqueue
<
iorecord
>
write_queue
;
bool
data_write_active
=
false
;
public:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment