Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
19e4672a
Commit
19e4672a
authored
May 17, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input/buffering: use notify_all() instead of notify_one()
More preparations to support multiple readers.
parent
c2dd6808
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
BufferingInputStream.cxx
src/input/BufferingInputStream.cxx
+10
-10
No files found.
src/input/BufferingInputStream.cxx
View file @
19e4672a
...
...
@@ -39,7 +39,7 @@ BufferingInputStream::~BufferingInputStream() noexcept
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
stop
=
true
;
wake_cond
.
notify_
one
();
wake_cond
.
notify_
all
();
}
thread
.
Join
();
...
...
@@ -73,7 +73,7 @@ BufferingInputStream::Seek(std::unique_lock<Mutex> &lock, size_t new_offset)
seek_offset
=
new_offset
;
seek
=
true
;
wake_cond
.
notify_
one
();
wake_cond
.
notify_
all
();
client_cond
.
wait
(
lock
,
[
this
]{
return
!
seek
;
});
...
...
@@ -105,7 +105,7 @@ BufferingInputStream::Read(std::unique_lock<Mutex> &lock, void *ptr, size_t s)
if
(
!
IsAvailable
())
{
/* wake up the sleeping thread */
wake_cond
.
notify_
one
();
wake_cond
.
notify_
all
();
}
return
nbytes
;
...
...
@@ -150,7 +150,7 @@ BufferingInputStream::RunThread() noexcept
}
seek
=
false
;
client_cond
.
notify_
one
();
client_cond
.
notify_
all
();
}
else
if
(
offset
!=
input
->
GetOffset
()
&&
!
IsAvailable
())
{
/* a past Seek() call was a no-op because data
was already available at that position, but
...
...
@@ -172,7 +172,7 @@ BufferingInputStream::RunThread() noexcept
own InputStream interface) is in
"read" mode */
read_error
=
std
::
current_exception
();
client_cond
.
notify_
one
();
client_cond
.
notify_
all
();
OnBufferAvailable
();
break
;
}
...
...
@@ -191,7 +191,7 @@ BufferingInputStream::RunThread() noexcept
input
->
Seek
(
lock
,
new_offset
);
}
catch
(...)
{
read_error
=
std
::
current_exception
();
client_cond
.
notify_
one
();
client_cond
.
notify_
all
();
OnBufferAvailable
();
break
;
}
...
...
@@ -215,7 +215,7 @@ BufferingInputStream::RunThread() noexcept
input
->
Seek
(
lock
,
new_offset
);
}
catch
(...)
{
read_error
=
std
::
current_exception
();
client_cond
.
notify_
one
();
client_cond
.
notify_
all
();
OnBufferAvailable
();
break
;
}
...
...
@@ -230,7 +230,7 @@ BufferingInputStream::RunThread() noexcept
input
->
Seek
(
lock
,
offset
);
}
catch
(...)
{
read_error
=
std
::
current_exception
();
client_cond
.
notify_
one
();
client_cond
.
notify_
all
();
OnBufferAvailable
();
break
;
}
...
...
@@ -246,12 +246,12 @@ BufferingInputStream::RunThread() noexcept
read_offset
+
nbytes
);
}
catch
(...)
{
read_error
=
std
::
current_exception
();
client_cond
.
notify_
one
();
client_cond
.
notify_
all
();
OnBufferAvailable
();
break
;
}
client_cond
.
notify_
one
();
client_cond
.
notify_
all
();
OnBufferAvailable
();
}
else
wake_cond
.
wait
(
lock
);
...
...
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