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
d3c7fac6
Commit
d3c7fac6
authored
Jun 17, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread/Thread: throw std::system_error on error
parent
fea3f6cc
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
21 additions
and
53 deletions
+21
-53
IOThread.cxx
src/IOThread.cxx
+1
-6
Service.cxx
src/db/update/Service.cxx
+1
-5
DecoderThread.cxx
src/decoder/DecoderThread.cxx
+1
-5
ThreadInputStream.cxx
src/input/ThreadInputStream.cxx
+3
-7
ThreadInputStream.hxx
src/input/ThreadInputStream.hxx
+1
-3
MmsInputPlugin.cxx
src/input/plugins/MmsInputPlugin.cxx
+3
-6
SmbclientNeighborPlugin.cxx
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
+3
-2
OutputThread.cxx
src/output/OutputThread.cxx
+1
-4
Thread.cxx
src/player/Thread.cxx
+1
-4
Thread.cxx
src/thread/Thread.cxx
+5
-8
Thread.hxx
src/thread/Thread.hxx
+1
-3
No files found.
src/IOThread.cxx
View file @
d3c7fac6
...
...
@@ -24,8 +24,6 @@
#include "thread/Thread.hxx"
#include "thread/Name.hxx"
#include "event/Loop.hxx"
#include "system/FatalError.hxx"
#include "util/Error.hxx"
#include <assert.h>
...
...
@@ -75,10 +73,7 @@ io_thread_start()
assert
(
!
io
.
thread
.
IsDefined
());
const
ScopeLock
protect
(
io
.
mutex
);
Error
error
;
if
(
!
io
.
thread
.
Start
(
io_thread_func
,
nullptr
,
error
))
FatalError
(
error
);
io
.
thread
.
Start
(
io_thread_func
,
nullptr
);
}
void
...
...
src/db/update/Service.cxx
View file @
d3c7fac6
...
...
@@ -27,9 +27,7 @@
#include "db/plugins/simple/Directory.hxx"
#include "storage/CompositeStorage.hxx"
#include "Idle.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "system/FatalError.hxx"
#include "thread/Thread.hxx"
#include "thread/Util.hxx"
...
...
@@ -160,9 +158,7 @@ UpdateService::StartThread(UpdateQueueItem &&i)
next
=
std
::
move
(
i
);
walk
=
new
UpdateWalk
(
GetEventLoop
(),
listener
,
*
next
.
storage
);
Error
error
;
if
(
!
update_thread
.
Start
(
Task
,
this
,
error
))
FatalError
(
error
);
update_thread
.
Start
(
Task
,
this
);
FormatDebug
(
update_domain
,
"spawned thread for update job id %i"
,
next
.
id
);
...
...
src/decoder/DecoderThread.cxx
View file @
d3c7fac6
...
...
@@ -24,7 +24,6 @@
#include "DecoderError.hxx"
#include "DecoderPlugin.hxx"
#include "DetachedSong.hxx"
#include "system/FatalError.hxx"
#include "MusicPipe.hxx"
#include "fs/Traits.hxx"
#include "fs/AllocatedPath.hxx"
...
...
@@ -520,8 +519,5 @@ decoder_thread_start(DecoderControl &dc)
assert
(
!
dc
.
thread
.
IsDefined
());
dc
.
quit
=
false
;
Error
error
;
if
(
!
dc
.
thread
.
Start
(
decoder_task
,
&
dc
,
error
))
FatalError
(
error
);
dc
.
thread
.
Start
(
decoder_task
,
&
dc
);
}
src/input/ThreadInputStream.cxx
View file @
d3c7fac6
...
...
@@ -44,8 +44,8 @@ ThreadInputStream::~ThreadInputStream()
}
}
InputStream
*
ThreadInputStream
::
Start
(
Error
&
error
)
void
ThreadInputStream
::
Start
()
{
assert
(
buffer
==
nullptr
);
...
...
@@ -53,11 +53,7 @@ ThreadInputStream::Start(Error &error)
assert
(
p
!=
nullptr
);
buffer
=
new
CircularBuffer
<
uint8_t
>
((
uint8_t
*
)
p
,
buffer_size
);
if
(
!
thread
.
Start
(
ThreadFunc
,
this
,
error
))
return
nullptr
;
return
this
;
thread
.
Start
(
ThreadFunc
,
this
);
}
inline
void
...
...
src/input/ThreadInputStream.hxx
View file @
d3c7fac6
...
...
@@ -78,10 +78,8 @@ public:
/**
* Initialize the object and start the thread.
*
* @return false on error
*/
InputStream
*
Start
(
Error
&
error
);
void
Start
(
);
/* virtual methods from InputStream */
bool
Check
(
Error
&
error
)
override
final
;
...
...
src/input/plugins/MmsInputPlugin.cxx
View file @
d3c7fac6
...
...
@@ -73,7 +73,7 @@ MmsInputStream::Open(Error &error)
static
InputStream
*
input_mms_open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
gcc_unused
Error
&
error
)
{
if
(
!
StringStartsWith
(
url
,
"mms://"
)
&&
!
StringStartsWith
(
url
,
"mmsh://"
)
&&
...
...
@@ -82,11 +82,8 @@ input_mms_open(const char *url,
return
nullptr
;
auto
m
=
new
MmsInputStream
(
url
,
mutex
,
cond
);
auto
is
=
m
->
Start
(
error
);
if
(
is
==
nullptr
)
delete
m
;
return
is
;
m
->
Start
();
return
m
;
}
size_t
...
...
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
View file @
d3c7fac6
...
...
@@ -83,10 +83,11 @@ private:
};
bool
SmbclientNeighborExplorer
::
Open
(
Error
&
error
)
SmbclientNeighborExplorer
::
Open
(
gcc_unused
Error
&
error
)
{
quit
=
false
;
return
thread
.
Start
(
ThreadFunc
,
this
,
error
);
thread
.
Start
(
ThreadFunc
,
this
);
return
true
;
}
void
...
...
src/output/OutputThread.cxx
View file @
d3c7fac6
...
...
@@ -33,7 +33,6 @@
#include "thread/Util.hxx"
#include "thread/Slack.hxx"
#include "thread/Name.hxx"
#include "system/FatalError.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "Log.hxx"
...
...
@@ -709,7 +708,5 @@ AudioOutput::StartThread()
{
assert
(
command
==
Command
::
NONE
);
Error
error
;
if
(
!
thread
.
Start
(
Task
,
this
,
error
))
FatalError
(
error
);
thread
.
Start
(
Task
,
this
);
}
src/player/Thread.cxx
View file @
d3c7fac6
...
...
@@ -26,7 +26,6 @@
#include "MusicBuffer.hxx"
#include "MusicChunk.hxx"
#include "DetachedSong.hxx"
#include "system/FatalError.hxx"
#include "CrossFade.hxx"
#include "Control.hxx"
#include "output/MultipleOutputs.hxx"
...
...
@@ -1235,7 +1234,5 @@ StartPlayerThread(PlayerControl &pc)
{
assert
(
!
pc
.
thread
.
IsDefined
());
Error
error
;
if
(
!
pc
.
thread
.
Start
(
player_task
,
&
pc
,
error
))
FatalError
(
error
);
pc
.
thread
.
Start
(
player_task
,
&
pc
);
}
src/thread/Thread.cxx
View file @
d3c7fac6
...
...
@@ -19,14 +19,14 @@
#include "config.h"
#include "Thread.hxx"
#include "
util
/Error.hxx"
#include "
system
/Error.hxx"
#ifdef ANDROID
#include "java/Global.hxx"
#endif
bool
Thread
::
Start
(
void
(
*
_f
)(
void
*
ctx
),
void
*
_ctx
,
Error
&
error
)
Thread
::
Start
(
void
(
*
_f
)(
void
*
ctx
),
void
*
_ctx
)
{
assert
(
!
IsDefined
());
...
...
@@ -35,10 +35,8 @@ Thread::Start(void (*_f)(void *ctx), void *_ctx, Error &error)
#ifdef WIN32
handle
=
::
CreateThread
(
nullptr
,
0
,
ThreadProc
,
this
,
0
,
&
id
);
if
(
handle
==
nullptr
)
{
error
.
SetLastError
(
"Failed to create thread"
);
return
false
;
}
if
(
handle
==
nullptr
)
throw
MakeLastError
(
"Failed to create thread"
);
#else
#ifndef NDEBUG
creating
=
true
;
...
...
@@ -50,8 +48,7 @@ Thread::Start(void (*_f)(void *ctx), void *_ctx, Error &error)
#ifndef NDEBUG
creating
=
false
;
#endif
error
.
SetErrno
(
e
,
"Failed to create thread"
);
return
false
;
throw
MakeErrno
(
e
,
"Failed to create thread"
);
}
defined
=
true
;
...
...
src/thread/Thread.hxx
View file @
d3c7fac6
...
...
@@ -31,8 +31,6 @@
#include <assert.h>
class
Error
;
class
Thread
{
#ifdef WIN32
HANDLE
handle
=
nullptr
;
...
...
@@ -91,7 +89,7 @@ public:
#endif
}
bool
Start
(
void
(
*
f
)(
void
*
ctx
),
void
*
ctx
,
Error
&
error
);
bool
Start
(
void
(
*
f
)(
void
*
ctx
),
void
*
ctx
);
void
Join
();
private
:
...
...
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