Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
3e88d785
Commit
3e88d785
authored
Jan 25, 2014
by
gabi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor comments
parent
60c3bb3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
blocking_queue.h
include/c11log/details/blocking_queue.h
+10
-10
No files found.
include/c11log/details/blocking_queue.h
View file @
3e88d785
...
...
@@ -35,7 +35,7 @@ public:
}
// Push copy of item into the back of the queue.
// If queue is full, block the calling thread util there is room or timeout have passed.
// If
the
queue is full, block the calling thread util there is room or timeout have passed.
// Return: false on timeout, true on successful push.
template
<
class
Duration_Rep
,
class
Duration_Period
>
bool
push
(
const
T
&
item
,
const
std
::
chrono
::
duration
<
Duration_Rep
,
Duration_Period
>&
timeout
)
...
...
@@ -47,24 +47,24 @@ public:
return
false
;
}
_q
.
push
(
item
);
if
(
_q
.
size
()
=
=
1
)
if
(
_q
.
size
()
<
=
1
)
{
ul
.
unlock
();
ul
.
unlock
();
//So the notified thread will have better chance to accuire the lock immediatly..
_item_pushed_cond
.
notify_one
();
}
return
true
;
}
// Push copy of item into the back of the queue.
// If
queue is full, block the calling thread until there is room
// If
the queue is full, block the calling thread until there is room.
void
push
(
const
T
&
item
)
{
while
(
!
push
(
item
,
std
::
chrono
::
hours
::
max
()));
}
// Pop a copy of the front item in the queue into the given item ref
// If queue is empty, block the calling thread util there is item to pop or timeout have passed.
// Return: false on timeout , true on successful pop
// Pop a copy of the front item in the queue into the given item ref
.
// If
the
queue is empty, block the calling thread util there is item to pop or timeout have passed.
// Return: false on timeout , true on successful pop
/
template
<
class
Duration_Rep
,
class
Duration_Period
>
bool
pop
(
T
&
item
,
const
std
::
chrono
::
duration
<
Duration_Rep
,
Duration_Period
>&
timeout
)
{
...
...
@@ -78,14 +78,14 @@ public:
_q
.
pop
();
if
(
_q
.
size
()
>=
_max_size
-
1
)
{
ul
.
unlock
();
ul
.
unlock
();
//So the notified thread will have better chance to accuire the lock immediatly..
_item_popped_cond
.
notify_one
();
}
return
true
;
}
// Pop a copy of the front item in the queue into the given item ref
// If queue is empty, block the calling thread util there is item to pop.
// Pop a copy of the front item in the queue into the given item ref
.
// If
the
queue is empty, block the calling thread util there is item to pop.
void
pop
(
T
&
item
)
{
while
(
!
pop
(
item
,
std
::
chrono
::
hours
::
max
()));
...
...
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