event/{Idle,Defer}Event: use base_hook instead of member_hook

Allows forward declaration.
This commit is contained in:
Max Kellermann 2020-10-14 14:02:11 +02:00
parent 1686f4e857
commit b06c4e2711
3 changed files with 10 additions and 16 deletions

View File

@ -31,12 +31,11 @@ class EventLoop;
*
* This class is thread-safe.
*/
class DeferEvent final {
class DeferEvent final
: public boost::intrusive::list_base_hook<>
{
friend class EventLoop;
typedef boost::intrusive::list_member_hook<> ListHook;
ListHook list_hook;
EventLoop &loop;
typedef BoundMethod<void() noexcept> Callback;
@ -59,7 +58,7 @@ public:
private:
bool IsPending() const noexcept {
return list_hook.is_linked();
return is_linked();
}
void RunDeferred() noexcept {

View File

@ -34,12 +34,11 @@ class EventLoop;
* thread that runs the #EventLoop, except where explicitly documented
* as thread-safe.
*/
class IdleEvent {
class IdleEvent
: public boost::intrusive::list_base_hook<>
{
friend class EventLoop;
using ListHook = boost::intrusive::list_member_hook<>;
ListHook list_hook;
EventLoop &loop;
using Callback = BoundMethod<void() noexcept>;
@ -63,7 +62,7 @@ public:
}
bool IsActive() const noexcept {
return list_hook.is_linked();
return is_linked();
}
void Schedule() noexcept;

View File

@ -72,9 +72,7 @@ class EventLoop final : SocketMonitor
using IdleList =
boost::intrusive::list<IdleEvent,
boost::intrusive::member_hook<IdleEvent,
IdleEvent::ListHook,
&IdleEvent::list_hook>,
boost::intrusive::base_hook<boost::intrusive::list_base_hook<>>,
boost::intrusive::constant_time_size<false>>;
IdleList idle;
@ -82,9 +80,7 @@ class EventLoop final : SocketMonitor
using DeferredList =
boost::intrusive::list<DeferEvent,
boost::intrusive::member_hook<DeferEvent,
DeferEvent::ListHook,
&DeferEvent::list_hook>,
boost::intrusive::base_hook<boost::intrusive::list_base_hook<>>,
boost::intrusive::constant_time_size<false>>;
DeferredList deferred;