Max Kellermann
ce68701c0c
event/Loop: add flag "dead"
2018-01-29 22:52:13 +01:00
Max Kellermann
199c8aaa25
event/Loop: move code to HandleTimers()
2018-01-29 22:40:12 +01:00
Max Kellermann
3890bc5a96
event/Loop: add "noexcept"
2018-01-29 22:05:58 +01:00
Max Kellermann
497e0669ff
event/PollResult: use size_t for size and index
2018-01-29 21:56:12 +01:00
Max Kellermann
f8bb66b4e0
event/Loop: use std::atomic_bool for the "quit" variable
...
Fixes thread sanitizer warnings.
2017-12-22 11:04:24 +01:00
Max Kellermann
b57e2f5521
event/DeferredMonitor: eliminate obsolete class
...
Move its code to DeferEvent instead.
2017-11-12 17:34:06 +01:00
Max Kellermann
59a8836924
event/SocketMonitor: add "noexcept"
2017-11-10 20:20:07 +01:00
Max Kellermann
30a5dd267b
event/TimeoutMonitor: move code to new class TimerEvent
2017-08-29 16:28:27 +02:00
Max Kellermann
2f0d683378
event/Loop: fix inverted checkin RemoveDeferred()
2017-08-29 16:28:24 +02:00
Max Kellermann
a1309a90ac
event/Loop: use boost::intrusive::list to store IdleMonitors and DeferredMonitors
...
The intrusive contains can easily erase items without searching
through the whole list. This removes a good amount of runtime
overhead.
2017-08-29 15:43:16 +02:00
Max Kellermann
010855a294
event/Loop: use boost::intrusive::multiset to store TimeoutMonitors
...
By using an "intrusive" data structure, we can easily eliminate
struct TimerRecord.
2017-08-29 14:42:59 +02:00
Max Kellermann
71ed3ff992
event/Loop: move TimerRecord::due to class TimeoutMonitor
...
Prepare to eliminate the TimerRecord struct.
2017-08-29 14:13:09 +02:00
Max Kellermann
5ac72211cd
event/Loop: set thread to current thread by default
...
Allows eliminating lots of complexity and workarounds for bogus
assertion failures.
2017-08-18 18:18:55 +02:00
Max Kellermann
7f9a2f8adb
event/Loop: schedule and cancel the WakeFD in Run()
...
This is only needed while Run() is alive, and moving it there avoids
problems with thread-checking assertions.
2017-08-18 18:08:06 +02:00
Max Kellermann
492b20a89d
event/SocketMonitor: use class SocketDescriptor
2017-08-10 19:19:58 +02:00
Max Kellermann
115af4f565
event/Loop: Break() is no-op if "quit" is already set
2017-02-10 22:24:48 +01:00
Max Kellermann
14986b153a
event/Loop: use std::lock_guard
2017-02-09 21:26:55 +01:00
Max Kellermann
7372c931b3
event/Loop: make IsInsideOrNull() available in the NDEBUG build
...
Fixes build breakage by commit 4e5271fcdf7; and this method does make
sense in non-debug builds.
2017-02-09 21:21:49 +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
b042095ac2
event/Loop: use std::chrono
2016-12-28 01:15:08 +01:00
Max Kellermann
018c5ef731
event/Loop: use C++11 initializers
2016-12-27 23:13:26 +01:00
Max Kellermann
1d67aa7bf2
update copyright year to 2016
2016-02-26 17:54:05 +01:00
Max Kellermann
712ed555e6
Copyright year 2015
2015-01-01 19:48:13 +01:00
Max Kellermann
3c29aa6271
event/Loop: read the "again" flag while holding mutex
2014-12-14 14:47:36 +01:00
Max Kellermann
4a28333039
event/Loop: remove the dummy constructor argument
2014-02-05 00:00:03 +01:00
Max Kellermann
4f83c60296
copyright year 2014
2014-01-13 22:31:55 +01:00
Max Kellermann
eb23ef1747
event/Loop: allow AddTimer() after Run() has returned
...
Kludge for libavahi-client quirk.
2014-01-09 20:56:00 +01:00
Max Kellermann
61b938d6fa
event/Loop: allow scheduling events before Run()
...
Add the debug-only flag "virgin" which gets checked by assert()
calls. Fixes assertion failures when using zeroconf/avahi.
2014-01-09 17:52:55 +01:00
Max Kellermann
582c2105a9
event/Loop: cancel the WakeFD monitor in destructor
2014-01-06 21:57:40 +01:00
Max Kellermann
793962c5b8
event/SocketMonitor: don't close the socket automatically
...
Users now have to call Close() explicitly. This simplifies using the
class, as most users have automatic socket management already, and
Steal() had to be used often.
2014-01-06 18:26:55 +01:00
Max Kellermann
e599b86424
event/Loop: try to avoid the WakeFD when adding DeferredMonitor
...
Add a flag that indicates whether the EventLoop is currently "busy".
As long as that flag is set, it does not need to be woken up - we can
simply add the DeferredMonitor to the list, and it will be caught by
EventLoop very soon. This eliminates nearly all of the
DeferredMonitor overhead when compared to IdleMonitor, rendering
IdleMonitor mostly obsolete.
2014-01-05 02:15:34 +01:00
Max Kellermann
da9e584921
event/Loop: combine multiple WakeFD::Write() calls
...
Reduce DeferredMonitor overhead.
2014-01-05 02:15:10 +01:00
Max Kellermann
e9d764d7ad
event/Loop: add attribute "again"
...
Improved support for added events.
2014-01-05 02:15:01 +01:00
Max Kellermann
6268955778
event/Loop: add thread-safety assertions
2014-01-05 02:14:31 +01:00
Max Kellermann
c12da599b9
event/Loop: remove obsolete assertion
2014-01-05 01:41:03 +01:00
Max Kellermann
f685a48008
event/Loop: move code to HandleDeferred()
2014-01-05 01:35:12 +01:00
Max Kellermann
f0d3b47ad8
event/Loop: remove the GLib implementation
...
Now that the remaining known bugs in poll() implementation are fixed,
we can go on without the GLib implementation.
2014-01-04 19:31:23 +01:00
Max Kellermann
19424e95db
event/Loop: remove bogus "!quit" assertion
...
Commit 1f11959
allowed modifying the "quit" attribute from any thread,
and thus the assertion may fail spuriously. This assertion is too
strict for the relaxed use of "quit". Let's remove it and move the
"quit" check to before the SockedMonitor::Dispatch() call.
2014-01-04 17:06:05 +01:00
Max Kellermann
0f9ef2506f
event/Loop: remove unused method AddCall()
2014-01-04 16:00:45 +01:00
Max Kellermann
1f1195975f
event/Loop: non-recursive Break() implementation
...
Simply set the "quit" flag and wake up the thread. This works even if
we're inside this thread. Setting "quit" to a new value without mutex
protection is usually not safe, but good enough here.
2014-01-04 15:59:00 +01:00
Max Kellermann
a357d84dce
event/DeferredMonitor: make fully thread-safe
...
Instead of creating a new eventfd for each DeferredMonitor instance,
reuse EventLoop's eventfd, and add a std::list to EventLoop that
manages the list of pending DeferredMonitors. This std::list is
protected by the same mutex as the "calls" list.
The bottom line is: reduced overhead because the per-instance eventfd
was eliminated, slightly added overhead due to Mutex usage (but
negligible), and we're thread-safe now.
This subsystem is now good enough to replace EventLoop::AddCall().
2014-01-04 15:58:59 +01:00
Denis Krjuchkov
bb288f0284
event: introduce generic API for internal event loop
2013-11-28 17:06:16 +06:00
Denis Krjuchkov
46bab7e4b9
Add infrastructure for using multiple event loops
...
This change adds two configuration options:
--with-eventloop=[glib|internal|auto]
--with-pollmethod=[epoll|auto]
First allows switching between GLib event loop and internal one.
Second chooses backend to use for internal event loop.
Conditional compilation symbols are changed accordingly.
Additional helper macro MPD_OPTIONAL_FUNC_NODEF is added as well.
2013-11-27 17:28:36 +06:00
Max Kellermann
154bdf0bca
event/SocketMonitor: add method Abandon()
2013-11-06 19:05:45 +01:00
Max Kellermann
20597b3632
*: use nullptr instead of NULL
2013-10-28 23:58:17 +01:00
Max Kellermann
0c13703da3
system/clock: convert to C++
2013-10-15 09:38:12 +02:00
Max Kellermann
00420ef9ca
EventLoop: initialise the thread id explicitly
2013-08-10 14:01:55 +02:00
Max Kellermann
c1f4f1fdb6
EventLoop: new implementation using epoll
...
Implement an event loop without GLib.
2013-08-10 13:54:23 +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