Max Kellermann
b1b731340e
event/PollBackend: add Item constructor
2020-10-30 16:32:45 +01:00
Max Kellermann
b9b02b4ff2
event/PollBackend: use unordered_map::find() instead of operator[]
...
The latter creates a new object, but we know that the key already
exists.
2020-10-30 16:25:41 +01:00
Max Kellermann
ab5d23da11
event/PollBackend: use unordered_map::emplace() in Add()
2020-10-30 16:24:32 +01:00
Max Kellermann
0554fe3652
event/PollBackend: use std::size_t
2020-10-30 16:09:29 +01:00
Max Kellermann
b0282fe36f
event/PollGroupWinSelect: add Item constructor
2020-10-30 16:07:23 +01:00
Max Kellermann
69b45e693b
event/WinSelect: use unordered_map::find() instead of operator[]
...
The latter creates a new object, but we know that the key already
exists.
2020-10-30 16:05:25 +01:00
Max Kellermann
9e97acc28d
event/WinSelect: merge duplicate code into ApplyReady()
2020-10-30 15:55:23 +01:00
Max Kellermann
b1e446a931
event/WinSelect: add missing const
to deleted copy ctor/operator
2020-10-30 15:45:29 +01:00
Max Kellermann
938319cd44
event/WinSelect: reorder method prototypes
2020-10-30 15:45:12 +01:00
Max Kellermann
fee29001fa
event/WinSelect: use unordered_map::emplace() in Add()
...
This allow using erase() with iterator, without a key lookup.
2020-10-30 15:32:11 +01:00
Max Kellermann
6d894a1806
event/WinSelect: use SOCKET as std::unordered_map key
2020-10-30 15:25:09 +01:00
Max Kellermann
7c47fe746c
event/Loop: AbandonFD() unlinks the SocketEvent
...
Fixes use-after-free bugs causing assertion failures at shutdown,
because all "abandoned" SocketEvents are still in the linked list.
Closes https://github.com/MusicPlayerDaemon/MPD/issues/986
Closes https://github.com/MusicPlayerDaemon/MPD/issues/987
2020-10-28 15:01:32 +01:00
Max Kellermann
65a1c4a016
event/Loop: pass SocketEvent& to AbandonFD()
2020-10-28 14:59:28 +01:00
Max Kellermann
46418d0f2d
event/ServerSocket: remove obsolete API documentation
2020-10-28 14:52:31 +01:00
Max Kellermann
8348a1ec8f
event/PollGroup: rename to PollBackend
2020-10-19 14:52:59 +02:00
Max Kellermann
c18e00daa4
event/PollGroup: move event flags to a separate header
...
Reduce header dependencies for SocketEvent.hxx.
2020-10-19 14:48:41 +02:00
Max Kellermann
418ba96334
event/SocketEvent: forbid copying
2020-10-18 20:07:49 +02:00
Max Kellermann
a60e782959
event/Loop: reorder assertions
2020-10-18 20:05:22 +02:00
Max Kellermann
8bab5733d7
event/Loop: add assertions
2020-10-18 20:04:16 +02:00
Max Kellermann
e3270dfd68
event/SocketEvent: use class IntrusiveList<>
2020-10-18 20:02:47 +02:00
Max Kellermann
a14997ffb8
event/Loop: manage all SocketEvents in a linked list
...
Not only those which are "ready".
2020-10-18 20:01:38 +02:00
Max Kellermann
dd94f97572
event/Loop: un-inline AddFD(), ModifyFD()
...
Prepare for adding more code here.
2020-10-18 19:58:42 +02:00
Max Kellermann
7d502fb448
event/Loop: round epoll_wait() timeout up
...
This implements proper rounding, amending commit dcbb9fe07c
2020-10-18 19:58:42 +02:00
Max Kellermann
f64799622d
event/IdleEvent: use class IntrusiveList<>
2020-10-18 19:28:12 +02:00
Max Kellermann
b5750afb24
event/IdleEvent: use auto
2020-10-18 19:23:34 +02:00
Max Kellermann
442dd5e955
event/IdleEvent: forbid copying
2020-10-18 19:23:25 +02:00
Max Kellermann
cb382b1e7d
event/PollGroupWinSelect: add missing return value
...
Fixes regression from commit 1473d8474f
2020-10-16 19:02:00 +02:00
Max Kellermann
b611b1824a
event/Loop: move code to Wait()
2020-10-15 20:21:00 +02:00
Max Kellermann
1473d8474f
event/PollGroup: ReadEvents() returns PollResult
2020-10-15 20:15:09 +02:00
Max Kellermann
725985379a
event/SocketEvent: add ScheduleImplicit(), Is{Read,Write}Pending()
2020-10-15 17:01:30 +02:00
Max Kellermann
8849b9b62c
event/SocketEvent: move Abandon() up
2020-10-15 16:59:45 +02:00
Max Kellermann
caa2611ad5
event/SocketEvent: add Abandon()
2020-10-15 16:57:55 +02:00
Max Kellermann
f8ff597963
event/SocketEvent: document Close()
2020-10-15 16:55:31 +02:00
Max Kellermann
ff6e434caf
event/SocketEvent: rename Steal() to ReleaseSocket()
2020-10-15 16:54:33 +02:00
Max Kellermann
55db7105c5
event/SocketEvent: check/clear scheduled_flags in Close()
...
Fixes regression by commit 521e573be9
2020-10-14 21:08:39 +02:00
Max Kellermann
48afb68f3a
event/SocketEvent: remove assert() from GetScheduledFlags()
...
Fixes regression by commit 7901b04c78
2020-10-14 20:50:02 +02:00
Max Kellermann
21f409d5e2
event/SocketEvent: fix grammar
2020-10-14 16:30:38 +02:00
Max Kellermann
521e573be9
event/SocketEvent: use EventLoop::AbandonFD() in Close()
2020-10-14 16:29:49 +02:00
Max Kellermann
abf9ae2dd9
event/Loop: rename Abandon() to AbandonFD()
2020-10-14 16:26:06 +02:00
Max Kellermann
9f013f7de4
event/SocketEvent: allow Close() without socket
2020-10-14 16:26:01 +02:00
Max Kellermann
7fc04fd5cd
event/SocketEvent: move Dispatch() down
2020-10-14 16:21:41 +02:00
Max Kellermann
7901b04c78
event/SocketEvent: allow Cancel() without socket
2020-10-14 16:20:43 +02:00
Max Kellermann
653eea5840
event/SocketEvent: remove unnecessary initializer
2020-10-14 16:18:39 +02:00
Max Kellermann
5a4055fb08
event/SocketMonitor: refactor to SocketEvent
...
Similar to commits 1686f4e857
and
30a5dd267b
2020-10-14 15:54:12 +02:00
Max Kellermann
4d68a12f03
event/Loop: split the AtScopeExit()
...
Fixes the !HAVE_THREADED_EVENT_LOOP build.
2020-10-14 14:47:59 +02:00
Max Kellermann
0e951da64b
event/Loop: add missing #ifdef
2020-10-14 14:37:29 +02:00
Max Kellermann
38dab040b3
event/Loop: add compile-time option to disable multithreading
...
Not for MPD, but for other applications which might want to copy its
event loop, but do not need multi-threading.
2020-10-14 14:08:38 +02:00
Max Kellermann
e9f6af61f9
event/Loop: forward-declare class {Idle,Defer}Event
2020-10-14 14:05:17 +02:00
Max Kellermann
b06c4e2711
event/{Idle,Defer}Event: use base_hook instead of member_hook
...
Allows forward declaration.
2020-10-14 14:04:30 +02:00
Max Kellermann
1686f4e857
event/IdleMonitor: refactor to IdleEvent
...
Instead of using this as a base class implementing a virtual method,
the new class IdleEvent can be used as a variable, decoupling
IdleMonitor's internal state from the derived class.
This is similar to commit 30a5dd267b
which refactored TimeoutMonitor to TimerEvent.
2020-10-14 13:47:25 +02:00