Max Kellermann
354104f9a9
thread/{Thread,Id}: use defaul-initialized pthread_t as "undefined" value
...
Use the "==" operator instead of pthread_equal().
This allows us to eliminate two boolean flags which are there to avoid
race conditions, and made the thing so fragile that I got tons of
(correct) thread sanitizer warnings.
2018-01-07 17:20:26 +01:00
Max Kellermann
8649ea3d6f
thread/Thread: use BoundMethod
2018-01-07 17:20:26 +01:00
Max Kellermann
752ff12c37
thread/Thread: move code to Run()
2018-01-07 17:20:26 +01:00
Max Kellermann
4a120f8090
Merge branch 'v0.20.x'
2018-01-05 10:10:17 +01:00
Max Kellermann
329f9cd9fe
thread/Util: no ioprio_set() on Android due to seccomp/SIGSYS
2018-01-04 19:33:14 +01:00
Max Kellermann
dbfc4abfd6
thread/SafeSingleton: disallow copying
2018-01-02 12:39:05 +01:00
Max Kellermann
5544375002
thread/SafeSingleton: pass parameters to constructor
2018-01-02 12:26:53 +01:00
Max Kellermann
196df1ccd5
thread/SafeSingleton: new thread-safe utility class
2018-01-02 12:10:41 +01:00
Max Kellermann
6a8c2848f6
thread/{Thread,Id}: use defaul-initialized pthread_t as "undefined" value
...
Use the "==" operator instead of pthread_equal().
This allows us to eliminate two boolean flags which are there to avoid
race conditions, and made the thing so fragile that I got tons of
(correct) thread sanitizer warnings.
2017-12-22 10:37:07 +01:00
Max Kellermann
b6af7abb1a
thread/PosixMutex: add "noexcept"
2017-12-18 23:29:08 +01:00
Max Kellermann
6246d36fe6
Merge branch 'v0.20.x'
2017-12-16 20:56:06 +01:00
Max Kellermann
dfaf08743c
*: check defined(_WIN32) instead of defined(WIN32)
...
Only _WIN32 is defined by the compiler, and WIN32 is not standardized
and may be missing.
Closes #169
2017-12-12 10:22:20 +01:00
Max Kellermann
618704f504
thread/*: add "noexcept"
2017-11-26 11:58:53 +01:00
Max Kellermann
979f1b6c39
release v0.20.9
...
-----BEGIN PGP SIGNATURE-----
iQJEBAABCAAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAlkz5jkQHG1heEBtdXNp
Y3BkLm9yZwAKCRAjbopYxttFEubuD/kBXMcV4XawqGNNtSHdrY8CxSL8wJMCMJQl
aMgRkKLPRml8Hj9FNNG9pjXBuT+qUgPX7t9gBEiT7c+sV3fHH40gUf1js5GIsEPm
BAVfvww5EhmQWWVhPTLk1iZ4jp6E96mDmIG1znwo7etSZHXU8RJfR7woBi3SPJ9f
OPcrimskNuWpAWeaEIKi/1Iwzy8d9VK9Ttb73gA3M5zSm7ioXzt3YClpwLRM8JU6
QeUJchy6VwXnygswjUNmbhPc3GsD2FyUZ4OtJ0hodnqqajfldBxhcHUnQk4zZULr
1nLSyOuA9bwLuFohH1T6HiY9z8PFzgqdIHvsjOJgZ4gQa69PVNjal2tUEUav9zFv
aK4LvTVPnIk+hqRbtLpV7/rPKuClrC9BO4oYdBGBDNY4hqVpvRA9obP1s00aOi+K
UhYqLqg7yeIEeTlUxFOhXJCKAEL69BuXT5ihJtDlB/dCUzv37sEch/4WDgs7uc+O
9kJYlElvozw57mbczsee/PCSnSWrLCq/qG/bNEUUQOTueWNuifh3PL62UXGgfbEH
01hJDyLr6ETSmWn7rjTfLJiHThX/EQQvOhs+35fbCyry65z4tFwrilGDmFVUWGPq
/6QEpY1D6q4fkoma/iWOZoTkfKewatAPGMGWoJaGhCnfQFz4VTFtS2bDtuUctQ16
jnXnPFxqBw==
=0SSp
-----END PGP SIGNATURE-----
Merge tag 'v0.20.9'
release v0.20.9
2017-06-04 12:57:05 +02:00
Max Kellermann
a057b4f6d8
*: add lost of "noexcept" specifications
2017-06-04 12:46:48 +02:00
Max Kellermann
4faef28cc5
release v0.20.7
...
-----BEGIN PGP SIGNATURE-----
iQJEBAABCAAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAlkaFL0QHG1heEBtdXNp
Y3BkLm9yZwAKCRAjbopYxttFEr4ID/9iAQC+7fFv06uLOm48Ufu+PgoD8uJkAwF5
QuLQkc85g9urn+bu9N7Qs7Vypp7aLyGcJKY0jyA8wxkOj24pUC3GYk80daUt561V
5s20FnoS/Uoman3CSJL94IfCUBxejizE6vgIIHTc5bb6U0qIsPub/8JTTE2Ih7uP
nvFZ5uBQ+YTc7at+iIH9123eUMKkitkh8osNblovqQT9v42++Tm4ztAytRHBjwUA
Itew5HhlvahbLKqFs/7vmICh/YX1FcOV7cV+erEWYfkH0KCI2bhSle4u2d0CBOvD
VJlDnBCo9bM7WKcPYqJiFFFXA0CRk06wbkkkAtwF4zjp8xos7aQcq4FyQnYL8KXo
5lijIhRwBURBd+nt8oA9kuEhBt/T75otcemJkzVaYappHTJCLjhxSGcPt8mw+nE9
9WQzsp/MIVzg9l5g3D9S/43xM7uhvn98Tn1Qf2s8YRd2o8CZeOhW+X3RvbCvVPv2
mOlx4sFAv8DOJ3KxMdqiJT+PmylPyJluQdqH+tMc8BdPg/kpSpYIPTuSjjRqK1yh
ld5do0HtAAwiHtvXfk5YVFjJSpO0c8yVn6xci2Cl4k/5ZHj2UE1ln+N5vCea2BRF
2J3HAjROwtcwY3lU1jFnEAogf24KWiFJqhhC0EqBGUdlrM8Dn37P5cEWWjROIMNK
lPEdovokNw==
=CdDy
-----END PGP SIGNATURE-----
Merge tag 'v0.20.7'
release v0.20.7
2017-05-15 23:01:49 +02:00
Max Kellermann
71f0ed8b74
*: add "noexcept" to many, many function prototypes
...
This eliminates some overhead, because the compiler doesn't need to
consider these functions throwing.
2017-05-08 14:44:49 +02:00
Max Kellermann
781487c4dd
thread/Thread: use BoundMethod
2017-02-10 22:46:09 +01:00
Max Kellermann
5ba5bc8ba1
thread/Thread: move code to Run()
2017-02-10 22:43:55 +01:00
Max Kellermann
82c66ce078
thread/Thread: Start() returns void
...
Since we switched to C++ exceptions, there is no code path which
returns false.
2017-02-10 22:41:29 +01:00
Max Kellermann
6eea56861b
AUTHORS, ...: update my email address
2017-01-17 11:54:55 +01:00
Max Kellermann
5900253b85
update copyright year
2017-01-03 20:48:59 +01:00
Max Kellermann
2e182e84c3
thread/Mutex: remove ScopeLock, use std::lock_guard directly
2017-01-03 07:11:57 +01:00
Max Kellermann
a42021655c
thread/Cond: make the integer-based timed_wait() overload private
...
Make sure this deprecated API is not used.
2017-01-03 07:07:10 +01:00
Max Kellermann
2498a2b0bd
thread/Mutex: use std::lock_guard instead of std::unique_lock
...
We need purely RAII-style, and this is std::lock_guard.
2017-01-03 06:56:24 +01:00
Max Kellermann
6fc47fbb69
thread/Mutex: make ScopeLock an alias for std::unique_lock
2016-12-29 11:53:24 +01:00
Max Kellermann
9c11184238
thread/Mutex: use std::unique_lock to implement ScopeLock
2016-12-29 11:51:25 +01:00
Max Kellermann
871ba5a488
thread/Cond: add timed_wait() overload with std::chrono support
2016-12-28 21:47:04 +01:00
Christian Körner
8bbfb5cda1
thread/PosixCond: fix timed_wait
...
pthread_cond_timedwait() in PosixCond.hxx:timed_wait(PosixMutex...) returns
EINVAL, if ts.tv_nsec >= 1E9. In this case, it returns to early.
Find attached a patch which fixes this. I chose a compare-subtraction method
to keep ts.tv_nsec below 1E9.
Another option would be
ts.tv_sec += ts.tv_nsec / 1000000000;
ts.tv_nsec %= 1000000000;
But I guess this takes more time on some ARM processors, which don't support
hardware division.
2016-09-19 11:21:21 +02:00
Max Kellermann
12091fcfb1
thread/Util: throw exception on error
2016-09-04 15:15:11 +02:00
Max Kellermann
5598826eaf
thread/Util: un-inline the functions
...
Reduce header clutter.
2016-09-04 15:11:56 +02:00
Max Kellermann
d3c7fac606
thread/Thread: throw std::system_error on error
2016-06-17 19:11:20 +02:00
Max Kellermann
fea3f6cc72
thread/Thread: use C++11 initialisers
2016-06-17 19:11:19 +02:00
Max Kellermann
eca6b9f0af
thread/Mutex: add method ScopeLock::Unlock()
2016-05-02 23:32:44 +02:00
Max Kellermann
1d67aa7bf2
update copyright year to 2016
2016-02-26 17:54:05 +01:00
Christian Halaszovich
3392cbbd91
Emit a warning if the OutputThread fails to get realtime scheduling
...
This only applies to linux systems. Here, sched_setscheduler() is
called to get realtime scheduling. With this patch, the return value
of this function is now checked and a warning / error message is
generated if it fails.
2016-02-19 17:09:44 +01:00
Max Kellermann
ac1eaff6ec
thread/Mutex: add class ScopeUnlock()
2015-12-31 12:30:53 +01:00
Max Kellermann
48d7fedbc0
thread/{Mutex,Cond}: remove obsolete comments
2015-08-25 12:52:13 +02:00
Max Kellermann
75dff64450
thread/Posix{Mutex,Cond}: use "constexpr" only with glibc
...
Apparently all other C libraries are not compatible with "constexpr".
Those which are not will get a performance penalty, but at least they
work at all.
2015-08-25 12:46:12 +02:00
Max Kellermann
ae7e1a22cb
Merge branch 'v0.19.x'
2015-01-26 20:57:29 +01:00
Max Kellermann
276a0d9500
thread/Name: include stdio.h if HAVE_PRCTL
...
Caused a build failure with uClibc because snprintf() was not
available.
2015-01-21 20:40:56 +01:00
Max Kellermann
674d14879f
Merge branch 'v0.19.x'
2015-01-06 12:54:46 +01:00
Max Kellermann
4bd2c75056
thread/Name: disable pthread_setname_np() on NetBSD
...
NetBSD's pthread_setname_np() prototype is incompatible with the rest
of the world, and it requires to pass the string argument as a
non-const pointer. Instead of working around this misdesign, I hereby
disable the feature on NetBSD.
2015-01-06 12:08:36 +01:00
Max Kellermann
b9ed850b98
thread/Name: enable FormatThreadName() with prctl()
...
Add macro HAVE_THREAD_NAME which is set when any method to set the
thread name is available. Use that macro in FormatThreadName()
instead of just checking for HAVE_PTHREAD_SETNAME_NP.
2015-01-06 12:04:30 +01:00
Max Kellermann
11cea17496
thread/Name: indent preprocessor commands
2015-01-06 12:04:15 +01:00
Max Kellermann
712ed555e6
Copyright year 2015
2015-01-01 19:48:13 +01:00
Max Kellermann
cbc1a58e93
release v0.18.20
...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAABAgAGBQJUha5vAAoJECNuiljG20USdLEP/0NCwdnvCPVdkZ7RwsdCRp53
jv86eu92uFVQJrW5/NQahngOwqNRsjNRX1EiEalbEjqCzMxDjuKCBukdteXg0Q2A
igwDDrDwpm9tvzilsTAdjEH3gRcuxDRWfF259bZXbnxksVMuwzo31YraU6dBUkSc
qPpQtbS4Op0paFG0TieBAt07TZ8Wb4KkAM86vBu31JpXZkXGyT6B6N3qe4WtpAN8
l5qAWstBRog5JM3Q99FNDnCFG/2n93CEZjwN8FlQgkFhyhhDKF5YOhZNQpqTEbh9
nxdo5V3OC42cx92V1CxrzkPKhnBIrSTGLg+Yb9S+vF3nWX+cBPpalr/rw5xZTrdH
3zER+hOHvkMZpEZDiyUx5bkF9Ay2BvJkdJCSFSTq9HmzksTnEJ+0r44cO2rwqOpx
R6KZPLTmObjCjmnMM+kbd6e/T8WEkcEotuYoocf3lep45roGAYuHErWW3+B89+4Z
f0Y8uwPQTWrOGSRKXh2liWcHeN114Uwvb0ZyO+/0Oe7v1Id/IW7zC2XfSpY58dok
/yRXiElow1LVLISixBBUAnwkx0M+CyQJqCS/nQpedPArLos+g4Wo3R+QnQEnOu9C
e1cRY3qa56lre6BnE+rQ3aMNVGgfjsU4t3mSjQlCp1PbU7izvlgMHJcyErt6d5aj
nA8VwjS+1PCODS/HkCqc
=APdC
-----END PGP SIGNATURE-----
Merge tag 'v0.18.20' into v0.19.x
2014-12-08 15:03:09 +01:00
Max Kellermann
d8fc2db910
thread/Id: drop "::" prefix before pthread function names
...
The "::" to explicitly refer to the global namespace appeared like a
good idea in C++, but it breaks with C libraries that implement
standard functions using macros (e.g. musl).
2014-12-08 14:17:17 +01:00
Max Kellermann
9270485723
Merge branch 'v0.18.x'
2014-09-24 21:49:20 +02:00
Max Kellermann
e304d0f8ee
thread/Posix{Cond,Mutex}: don't ues PTHREAD_*_INITIALIZER on NetBSD
...
On NetBSD, PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER are
not compatible with C++11 "constexpr" (see Mantis ticket 0004110). As
a workaround, don't ues "constexpr", and use the functions
pthread_mutex_init(), pthread_mutex_destroy(), pthread_cond_init() and
pthread_cond_destroy() instead. This adds some runtime overhead, but
is portable to POSIX implementations that have awkward initializer
macros.
2014-09-13 11:26:17 +02:00
Max Kellermann
56504534d8
thread/{Mutex,Cond}: relicense to BSD-2
2014-07-02 20:09:39 +02:00
Max Kellermann
80a45c91f9
thread/GLib{Mutex,Cond}: remove obsolete classes
2014-07-02 20:09:39 +02:00
Max Kellermann
dc14ac7a8f
thread/Util: relicense to BSD-2
2014-05-31 12:11:53 +02:00
Max Kellermann
d51b90a880
thread/Thread: make the destructor non-virtual
...
The class does not have any virtual methods, and thus the (debug-only)
destructor does not need to be virtual.
2014-03-16 10:26:23 +01:00
Max Kellermann
7453c26ec4
thread/Name: fall back to prctl()
2014-03-01 23:58:59 +01:00
Max Kellermann
1e06c66c77
java: new helper library for the Android port
2014-03-01 18:48:20 +01:00
Max Kellermann
a0c25941a8
Thread/Util: use __NR_ioprio_set instead of SYS_ioprio_set
...
Bionic doesn't have the SYS_* macros.
2014-02-18 10:44:18 +01:00
Max Kellermann
5eb468bce0
Thread/Util: make SCHED_RESET_ON_FORK optional
...
Use it if it exists, but don't insist if the C library is poor
(e.g. Bionic/Android).
2014-02-18 10:43:24 +01:00
Max Kellermann
9b7f492c65
thread/Posix{Mutex,Cond}: disable "constexpr" on Android
...
Bionic's pthread declarations are non-literal.
2014-02-18 09:54:35 +01:00
Max Kellermann
a31738f6f1
Main, OutputThread: increase kernel timer slack (Linux)
...
Allows the kernel to combine timer wakeups with other processes,
reducing power usage.
2014-01-30 18:43:40 +01:00
Max Kellermann
2f873edc9c
thread/Name: implementation for Mac OS X
...
pthread_setname_np() doesn't have the "thread" argument on OS X.
2014-01-28 11:33:15 +01:00
Max Kellermann
ec41d849bb
thread/Name: set thread names
...
For debugging.
2014-01-23 10:07:14 +01:00
Max Kellermann
1d547fe273
thread/Util: set the SCHED_RESET_ON_FORK flag in SetThreadRealtime()
2014-01-23 09:14:09 +01:00
Max Kellermann
4734af747b
OutputThread: use real-time priority
2014-01-14 09:59:04 +01:00
Max Kellermann
5d17731b73
UpdateGlue: let the update thread run at "idle" priority
...
The update thread should not affect the rest of the system, therefore
set "idle" priority, and let it only run when nobody else is using the
resources.
2014-01-14 09:09:52 +01:00
Max Kellermann
4f83c60296
copyright year 2014
2014-01-13 22:31:55 +01:00
Max Kellermann
8e676db633
Thread/Thread: replacement library for GThread
2013-10-17 19:29:47 +02:00
Max Kellermann
7c1cf61728
thread/{Cond,Mutex}: use "class" instead of "typedef"
...
Allows forward-declaration.
2013-10-17 10:06:31 +02:00
Max Kellermann
be2951b45f
gcc.h: rename to Compiler.h
2013-10-15 09:21:59 +02:00
Max Kellermann
d23c907a94
thread/Id: new class replacing GThread pointers
...
Remove a GLib dependencies from class EventLoop and DatabaseLock.
2013-08-10 09:00:04 +02:00
Max Kellermann
c5c43c4541
thread/Cond: add method timed_wait()
2013-04-17 01:33:07 +02:00
Max Kellermann
0226440a2d
thread/{Mutex,Cond}: new backend for WIN32
...
Use CRITICAL_SECTION and CONDITION_VARIABLE. This requires Windows
Vista or newer. It fixes problems with GLib threading objects that
were implicitly created by static constructors before g_thread_init().
2013-01-11 11:11:07 +01:00
Max Kellermann
0b93445380
thread/Cond: new wrapper for pthread_cond_t or GCond
2013-01-10 10:03:19 +01:00
Max Kellermann
483ba5ea1c
thread/GLibMutex: new Mutex implementation
...
Switch WIN32 to this implementation to be able to use condition
variables, which is impossible with CriticalSection.
2013-01-10 10:03:18 +01:00
Max Kellermann
51a8c109ab
thread/PosixMutex: fix indent
2013-01-10 10:00:52 +01:00
Max Kellermann
a68302e50b
thread/Mutex: don't use std::mutex
...
Use a custom pthread_mutex_t wrapper because std::mutex adds overhead.
2013-01-07 10:33:37 +01:00
Max Kellermann
efbfe66f21
Mutex: new wrapper for std::mutex, replaces GMutex
2013-01-04 21:24:29 +01:00