Commit Graph

96 Commits

Author SHA1 Message Date
Max Kellermann 98b29f6d1c meson.build: remove the libwinpthread-1.dll dependency on Windows
Closes https://github.com/MusicPlayerDaemon/MPD/issues/507
2019-03-14 20:07:06 +01:00
Max Kellermann ce49d99c2f check.h: remove obsolete header
Since we switched from autotools to Meson in commit
94592c1406, we don't need to include
`config.h` early to properly enable large file support.  Meson passes
the required macros on the compiler command line instead of defining
them in `config.h`.

This means we can include `config.h` at any time, whenever we want to
check its macros, and there are no ordering constraints.
2018-11-19 16:33:49 +01:00
Max Kellermann 2e450bbf95 src/thread/meson.build: detect pthread_setname_np()
This compile-time check got lost during the Meson transition.
2018-11-19 16:33:14 +01:00
Max Kellermann f5c9071494 *: copyright year 2018 2018-10-31 17:54:59 +01:00
Florian Schlichting db21d7de0b fix compilation errors on Debian GNU/Hurd
Apparently on hurd-i386 __GLIBC__ is defined, but the pthread
implementation is special and cannot be used with constexpr. Hence
exclude __gnu_hurd__.
2018-10-31 12:24:34 +01:00
Max Kellermann 94592c1406 build with Meson instead of autotools
So long, autotools!  This is my last MPD related project to migrate
away from it.  It has its strengths, but also very obvious weaknesses
and weirdnesses.  Today, many of its quirks are not needed anymore,
and are cumbersome and slow.  Now welcome our new Meson overlords!
2018-10-14 23:41:38 +02:00
Max Kellermann af64bd5088 Thread/Thread: disallow copying 2018-09-21 16:55:09 +02:00
Max Kellermann 050f81c4fe Thread/Thread: document Start() exception 2018-09-21 16:53:52 +02:00
Max Kellermann ec54754e22 Compiler.h: move to util/ 2018-08-20 16:19:17 +02:00
Yue Wang 866821765a
use uint_least32_t instead of long for timeout 2018-07-16 09:42:04 -07:00
Yue Wang 79937c9495
Support timed_wait in microseconds level
Some Audio plugin (such as ALSA, and soon CoreAudio) already support microsecond level buffer time. However, current interval less than 1000 microseconds will cause a bug that the code treated as 0 ms.
2018-07-15 13:22:53 -07:00
Max Kellermann 65bbb0e0aa release v0.20.17
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAlqAMO0QHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEg8eD/49NlFvlNdkamgYvh7MI1Sn67yKAwQt+N51
 W0hVnmXwPoSg76gfWw8J9kVyQy/jEkaCxsPF/UuEbH5jzqAC0y8hwYVRkJaRc9wN
 ZfwHvLHeaUxQweoguEwRSREy4ZC4ImQOK+eAxI1R43mqxxyhko1Akc1NmRVWzYfv
 /FGmAjTi1U6FR/yDpdSFn1NdlPmIgZ4WDuRsDT2NrshX/Bb32FiyZBytvek2P8n/
 QNgXv18E4yWXSb+zBYhPy/eaKhGasyjI3cbht1F0hNW9Yo/BsFxDuwXrX1vNBaOS
 E3Dux4s/nfcJ4RMRjmrkFwXImCvxt7+AGfh8RYBXuwqMExXz2kZjIs4ZVvO7Nu9A
 pFDJQwRIojXMfk73LU/MEpmNNEXhvfQLYkrM7poSqYaOr8SWMszqSgNnnfq6+flB
 sJbstgAStI6lL0jy0HrtMTvPVEiAGh6wCvMy/r2G9XUAyw76ccOg7MaIldn0MHJv
 A51+GfRTi4ILH0ReL1BGAg9nG97uFmRAWGkfkhtyD540xGRk7x5R8/ml4zFogHN6
 SbrV0NPdwk+uFd0y2znQT2gWyjc0id4WEKEoHX+Gl6c5qtPIfrq+PQPyk9kR+u+i
 AxwqMoKQer6Ji5qnsvCiKSkaGGiVNivrZ11jDWNCZaKjmvlKlvj/P5GxbPpORorq
 v4ru/4vNXQ==
 =v4t8
 -----END PGP SIGNATURE-----

Merge tag 'v0.20.17'

release v0.20.17
2018-02-11 13:22:43 +01:00
Max Kellermann 817656504d thread/Util: implement system call wrapper for sched_setscheduler()
There is a POSIX definition for sched_setscheduler(), but Linux does
not implement that; instead of changing the process's scheduler, it
only affects one thread.  This has caused some confusion among
application developers and C library developers.

While glibc implements Linux semantics, Musl has made their
sched_setscheduler() function an always-failing no-op, causing the
error message "sched_setscheduler failed: Function not implemented".

 http://git.musl-libc.org/cgit/musl/commit/src/sched/sched_setscheduler.c?id=1e21e78bf7a5c24c217446d8760be7b7188711c2

Instead of relying on the C library which may be unreliable here, we
now roll our own system call wrapper.

Closes #218
2018-02-09 18:43:45 +01:00
Max Kellermann 6f00f97b66 thread/Util: rename ioprio_set() to linux_ioprio_set()
Juse in cas glibc gets a wrapper for the system call which would then
conflict with ours.
2018-02-09 18:43:45 +01:00
Max Kellermann 97f670658f util/StringFormat: new utility library 2018-01-24 13:28:28 +01:00
Max Kellermann 96676f8f3b Merge branch 'v0.20.x' 2018-01-15 09:06:31 +01:00
Max Kellermann 2eef4e6716 thread/Thread: add debug attribute "inside_handle"
This attribute shall be used only for IsInside() to make this safe
against a race condition described in #188:

> There is no requirement on the implementation that the ID of the
> created thread be available before the newly created thread starts
> executing.

http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_create.html):

This means that on some pthread implementations (e.g. Haiku), the
assert(thread.IsInside()) could fail.

Closes #188
2018-01-08 09:58:18 +01:00
Max Kellermann d989dbfec4 thread/Thread: make IsInside() debug-only
This method is only used inside assert().
2018-01-08 09:56:39 +01:00
Max Kellermann ca9fcec364 thread/Thread: fix indent 2018-01-08 09:49:08 +01:00
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