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
618704f5
Commit
618704f5
authored
Nov 26, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread/*: add "noexcept"
parent
3b3ec402
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
44 additions
and
44 deletions
+44
-44
CriticalSection.hxx
src/thread/CriticalSection.hxx
+5
-5
Id.hxx
src/thread/Id.hxx
+3
-3
Mutex.hxx
src/thread/Mutex.hxx
+2
-2
Name.hxx
src/thread/Name.hxx
+2
-2
PosixCond.hxx
src/thread/PosixCond.hxx
+8
-8
Slack.hxx
src/thread/Slack.hxx
+3
-3
Thread.cxx
src/thread/Thread.cxx
+4
-4
Thread.hxx
src/thread/Thread.hxx
+7
-7
Util.cxx
src/thread/Util.cxx
+3
-3
Util.hxx
src/thread/Util.hxx
+1
-1
WindowsCond.hxx
src/thread/WindowsCond.hxx
+6
-6
No files found.
src/thread/CriticalSection.hxx
View file @
618704f5
...
...
@@ -41,26 +41,26 @@ class CriticalSection {
CRITICAL_SECTION
critical_section
;
public
:
CriticalSection
()
{
CriticalSection
()
noexcept
{
::
InitializeCriticalSection
(
&
critical_section
);
}
~
CriticalSection
()
{
~
CriticalSection
()
noexcept
{
::
DeleteCriticalSection
(
&
critical_section
);
}
CriticalSection
(
const
CriticalSection
&
other
)
=
delete
;
CriticalSection
&
operator
=
(
const
CriticalSection
&
other
)
=
delete
;
void
lock
()
{
void
lock
()
noexcept
{
::
EnterCriticalSection
(
&
critical_section
);
};
bool
try_lock
()
{
bool
try_lock
()
noexcept
{
return
::
TryEnterCriticalSection
(
&
critical_section
)
!=
0
;
};
void
unlock
()
{
void
unlock
()
noexcept
{
::
LeaveCriticalSection
(
&
critical_section
);
}
};
...
...
src/thread/Id.hxx
View file @
618704f5
...
...
@@ -44,12 +44,12 @@ public:
/**
* No initialisation.
*/
ThreadId
()
=
default
;
ThreadId
()
noexcept
=
default
;
#ifdef WIN32
constexpr
ThreadId
(
DWORD
_id
)
:
id
(
_id
)
{}
constexpr
ThreadId
(
DWORD
_id
)
noexcept
:
id
(
_id
)
{}
#else
constexpr
ThreadId
(
pthread_t
_id
)
:
id
(
_id
)
{}
constexpr
ThreadId
(
pthread_t
_id
)
noexcept
:
id
(
_id
)
{}
#endif
gcc_const
...
...
src/thread/Mutex.hxx
View file @
618704f5
...
...
@@ -52,11 +52,11 @@ class ScopeUnlock {
Mutex
&
mutex
;
public
:
explicit
ScopeUnlock
(
Mutex
&
_mutex
)
:
mutex
(
_mutex
)
{
explicit
ScopeUnlock
(
Mutex
&
_mutex
)
noexcept
:
mutex
(
_mutex
)
{
mutex
.
unlock
();
};
~
ScopeUnlock
()
{
~
ScopeUnlock
()
noexcept
{
mutex
.
lock
();
}
...
...
src/thread/Name.hxx
View file @
618704f5
...
...
@@ -35,7 +35,7 @@
#endif
static
inline
void
SetThreadName
(
const
char
*
name
)
SetThreadName
(
const
char
*
name
)
noexcept
{
#if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__NetBSD__)
/* not using pthread_setname_np() on NetBSD because it
...
...
@@ -56,7 +56,7 @@ SetThreadName(const char *name)
template
<
typename
...
Args
>
static
inline
void
FormatThreadName
(
const
char
*
fmt
,
gcc_unused
Args
&&
...
args
)
FormatThreadName
(
const
char
*
fmt
,
gcc_unused
Args
&&
...
args
)
noexcept
{
#ifdef HAVE_THREAD_NAME
char
buffer
[
16
];
...
...
src/thread/PosixCond.hxx
View file @
618704f5
...
...
@@ -46,15 +46,15 @@ public:
#ifdef __GLIBC__
/* optimized constexpr constructor for pthread implementations
that support it */
constexpr
PosixCond
()
:
cond
(
PTHREAD_COND_INITIALIZER
)
{}
constexpr
PosixCond
()
noexcept
:
cond
(
PTHREAD_COND_INITIALIZER
)
{}
#else
/* slow fallback for pthread implementations that are not
compatible with "constexpr" */
PosixCond
()
{
PosixCond
()
noexcept
{
pthread_cond_init
(
&
cond
,
nullptr
);
}
~
PosixCond
()
{
~
PosixCond
()
noexcept
{
pthread_cond_destroy
(
&
cond
);
}
#endif
...
...
@@ -62,20 +62,20 @@ public:
PosixCond
(
const
PosixCond
&
other
)
=
delete
;
PosixCond
&
operator
=
(
const
PosixCond
&
other
)
=
delete
;
void
signal
()
{
void
signal
()
noexcept
{
pthread_cond_signal
(
&
cond
);
}
void
broadcast
()
{
void
broadcast
()
noexcept
{
pthread_cond_broadcast
(
&
cond
);
}
void
wait
(
PosixMutex
&
mutex
)
{
void
wait
(
PosixMutex
&
mutex
)
noexcept
{
pthread_cond_wait
(
&
cond
,
&
mutex
.
mutex
);
}
private
:
bool
timed_wait
(
PosixMutex
&
mutex
,
unsigned
timeout_ms
)
{
bool
timed_wait
(
PosixMutex
&
mutex
,
unsigned
timeout_ms
)
noexcept
{
struct
timeval
now
;
gettimeofday
(
&
now
,
nullptr
);
...
...
@@ -93,7 +93,7 @@ private:
public
:
bool
timed_wait
(
PosixMutex
&
mutex
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
{
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
auto
timeout_ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
timeout
).
count
();
if
(
timeout_ms
<
0
)
timeout_ms
=
0
;
...
...
src/thread/Slack.hxx
View file @
618704f5
...
...
@@ -30,7 +30,7 @@
* merge multiple wakeups, which is a trick to save energy.
*/
static
inline
void
SetThreadTimerSlackNS
(
unsigned
long
slack_ns
)
SetThreadTimerSlackNS
(
unsigned
long
slack_ns
)
noexcept
{
#if defined(HAVE_PRCTL) && defined(PR_SET_TIMERSLACK)
prctl
(
PR_SET_TIMERSLACK
,
slack_ns
,
0
,
0
,
0
);
...
...
@@ -40,13 +40,13 @@ SetThreadTimerSlackNS(unsigned long slack_ns)
}
static
inline
void
SetThreadTimerSlackUS
(
unsigned
long
slack_us
)
SetThreadTimerSlackUS
(
unsigned
long
slack_us
)
noexcept
{
SetThreadTimerSlackNS
(
slack_us
*
1000ul
);
}
static
inline
void
SetThreadTimerSlackMS
(
unsigned
long
slack_ms
)
SetThreadTimerSlackMS
(
unsigned
long
slack_ms
)
noexcept
{
SetThreadTimerSlackNS
(
slack_ms
*
1000000ul
);
}
...
...
src/thread/Thread.cxx
View file @
618704f5
...
...
@@ -56,7 +56,7 @@ Thread::Start()
}
void
Thread
::
Join
()
Thread
::
Join
()
noexcept
{
assert
(
IsDefined
());
assert
(
!
IsInside
());
...
...
@@ -72,7 +72,7 @@ Thread::Join()
}
inline
void
Thread
::
Run
()
Thread
::
Run
()
noexcept
{
#ifndef WIN32
#ifndef NDEBUG
...
...
@@ -94,7 +94,7 @@ Thread::Run()
#ifdef WIN32
DWORD
WINAPI
Thread
::
ThreadProc
(
LPVOID
ctx
)
Thread
::
ThreadProc
(
LPVOID
ctx
)
noexcept
{
Thread
&
thread
=
*
(
Thread
*
)
ctx
;
...
...
@@ -105,7 +105,7 @@ Thread::ThreadProc(LPVOID ctx)
#else
void
*
Thread
::
ThreadProc
(
void
*
ctx
)
Thread
::
ThreadProc
(
void
*
ctx
)
noexcept
{
Thread
&
thread
=
*
(
Thread
*
)
ctx
;
...
...
src/thread/Thread.hxx
View file @
618704f5
...
...
@@ -54,19 +54,19 @@ class Thread {
#endif
public
:
explicit
Thread
(
Function
_f
)
:
f
(
_f
)
{}
explicit
Thread
(
Function
_f
)
noexcept
:
f
(
_f
)
{}
Thread
(
const
Thread
&
)
=
delete
;
#ifndef NDEBUG
~
Thread
()
{
~
Thread
()
noexcept
{
/* all Thread objects must be destructed manually by calling
Join(), to clean up */
assert
(
!
IsDefined
());
}
#endif
bool
IsDefined
()
const
{
bool
IsDefined
()
const
noexcept
{
#ifdef WIN32
return
handle
!=
nullptr
;
#else
...
...
@@ -91,15 +91,15 @@ public:
}
void
Start
();
void
Join
();
void
Join
()
noexcept
;
private
:
void
Run
();
void
Run
()
noexcept
;
#ifdef WIN32
static
DWORD
WINAPI
ThreadProc
(
LPVOID
ctx
);
static
DWORD
WINAPI
ThreadProc
(
LPVOID
ctx
)
noexcept
;
#else
static
void
*
ThreadProc
(
void
*
ctx
);
static
void
*
ThreadProc
(
void
*
ctx
)
noexcept
;
#endif
};
...
...
src/thread/Util.cxx
View file @
618704f5
...
...
@@ -41,13 +41,13 @@
#ifdef __linux__
static
int
ioprio_set
(
int
which
,
int
who
,
int
ioprio
)
ioprio_set
(
int
which
,
int
who
,
int
ioprio
)
noexcept
{
return
syscall
(
__NR_ioprio_set
,
which
,
who
,
ioprio
);
}
static
void
ioprio_set_idle
()
ioprio_set_idle
()
noexcept
{
static
constexpr
int
_IOPRIO_WHO_PROCESS
=
1
;
static
constexpr
int
_IOPRIO_CLASS_IDLE
=
3
;
...
...
@@ -61,7 +61,7 @@ ioprio_set_idle()
#endif
void
SetThreadIdlePriority
()
SetThreadIdlePriority
()
noexcept
{
#ifdef __linux__
#ifdef SCHED_IDLE
...
...
src/thread/Util.hxx
View file @
618704f5
...
...
@@ -34,7 +34,7 @@
* Lower the current thread's priority to "idle" (very low).
*/
void
SetThreadIdlePriority
();
SetThreadIdlePriority
()
noexcept
;
/**
* Raise the current thread's priority to "real-time" (very high).
...
...
src/thread/WindowsCond.hxx
View file @
618704f5
...
...
@@ -41,35 +41,35 @@ class WindowsCond {
CONDITION_VARIABLE
cond
;
public
:
WindowsCond
()
{
WindowsCond
()
noexcept
{
InitializeConditionVariable
(
&
cond
);
}
WindowsCond
(
const
WindowsCond
&
other
)
=
delete
;
WindowsCond
&
operator
=
(
const
WindowsCond
&
other
)
=
delete
;
void
signal
()
{
void
signal
()
noexcept
{
WakeConditionVariable
(
&
cond
);
}
void
broadcast
()
{
void
broadcast
()
noexcept
{
WakeAllConditionVariable
(
&
cond
);
}
private
:
bool
timed_wait
(
CriticalSection
&
mutex
,
DWORD
timeout_ms
)
{
bool
timed_wait
(
CriticalSection
&
mutex
,
DWORD
timeout_ms
)
noexcept
{
return
SleepConditionVariableCS
(
&
cond
,
&
mutex
.
critical_section
,
timeout_ms
);
}
public
:
bool
timed_wait
(
CriticalSection
&
mutex
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
{
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
auto
timeout_ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
timeout
).
count
();
return
timed_wait
(
mutex
,
timeout_ms
);
}
void
wait
(
CriticalSection
&
mutex
)
{
void
wait
(
CriticalSection
&
mutex
)
noexcept
{
timed_wait
(
mutex
,
INFINITE
);
}
};
...
...
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