Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
990f2dc1
Commit
990f2dc1
authored
Dec 01, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/DeferEvent: use class IntrusiveList instead of boost::intrusive::list
parent
774b4313
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
48 deletions
+24
-48
DeferEvent.cxx
src/event/DeferEvent.cxx
+4
-7
DeferEvent.hxx
src/event/DeferEvent.hxx
+12
-13
Loop.cxx
src/event/Loop.cxx
+5
-17
Loop.hxx
src/event/Loop.hxx
+3
-11
No files found.
src/event/DeferEvent.cxx
View file @
990f2dc1
...
...
@@ -21,13 +21,10 @@
#include "Loop.hxx"
void
DeferEvent
::
Cancel
()
noexcept
{
loop
.
RemoveDeferred
(
*
this
);
}
void
DeferEvent
::
Schedule
()
noexcept
{
loop
.
AddDeferred
(
*
this
);
if
(
!
IsPending
())
loop
.
AddDeferred
(
*
this
);
assert
(
IsPending
());
}
src/event/DeferEvent.hxx
View file @
990f2dc1
...
...
@@ -21,8 +21,7 @@
#define MPD_DEFER_EVENT_HXX
#include "util/BindMethod.hxx"
#include <boost/intrusive/list_hook.hpp>
#include "util/IntrusiveList.hxx"
class
EventLoop
;
...
...
@@ -34,10 +33,10 @@ class EventLoop;
* This class is not thread-safe, all methods must be called from the
* thread that runs the #EventLoop.
*/
class
DeferEvent
final
:
public
boost
::
intrusive
::
list_base_hook
<>
class
DeferEvent
final
:
AutoUnlinkIntrusiveListHook
{
friend
class
EventLoop
;
friend
class
IntrusiveList
<
DeferEvent
>
;
EventLoop
&
loop
;
...
...
@@ -51,23 +50,23 @@ public:
DeferEvent
(
const
DeferEvent
&
)
=
delete
;
DeferEvent
&
operator
=
(
const
DeferEvent
&
)
=
delete
;
~
DeferEvent
()
noexcept
{
Cancel
()
;
auto
&
GetEventLoop
()
const
noexcept
{
return
loop
;
}
EventLoop
&
GetEventLoop
()
const
noexcept
{
return
loop
;
bool
IsPending
()
const
noexcept
{
return
is_linked
()
;
}
void
Schedule
()
noexcept
;
void
Cancel
()
noexcept
;
private
:
bool
IsPending
()
const
noexcept
{
return
is_linked
();
void
Cancel
()
noexcept
{
if
(
IsPending
())
unlink
();
}
void
RunDeferred
()
noexcept
{
private
:
void
Run
()
noexcept
{
callback
();
}
};
...
...
src/event/Loop.cxx
View file @
990f2dc1
...
...
@@ -198,29 +198,17 @@ EventLoop::HandleTimers() noexcept
void
EventLoop
::
AddDeferred
(
DeferEvent
&
d
)
noexcept
{
if
(
d
.
IsPending
())
return
;
deferred
.
push_back
(
d
);
defer
.
push_back
(
d
);
again
=
true
;
}
void
EventLoop
::
RemoveDeferred
(
DeferEvent
&
d
)
noexcept
{
if
(
d
.
IsPending
())
deferred
.
erase
(
deferred
.
iterator_to
(
d
));
}
void
EventLoop
::
RunDeferred
()
noexcept
{
while
(
!
deferred
.
empty
()
&&
!
quit
)
{
auto
&
m
=
deferred
.
front
();
assert
(
m
.
IsPending
());
deferred
.
pop_front
();
m
.
RunDeferred
();
while
(
!
defer
.
empty
()
&&
!
quit
)
{
defer
.
pop_front_and_dispose
([](
DeferEvent
*
e
){
e
->
Run
();
});
}
}
...
...
src/event/Loop.hxx
View file @
990f2dc1
...
...
@@ -79,11 +79,9 @@ class EventLoop final
boost
::
intrusive
::
constant_time_size
<
false
>>
;
TimerSet
timers
;
using
DeferList
=
boost
::
intrusive
::
list
<
DeferEvent
,
boost
::
intrusive
::
base_hook
<
boost
::
intrusive
::
list_base_hook
<>>
,
boost
::
intrusive
::
constant_time_size
<
false
>>
;
DeferList
deferred
;
using
DeferList
=
IntrusiveList
<
DeferEvent
>
;
DeferList
defer
;
using
IdleList
=
IntrusiveList
<
IdleEvent
>
;
IdleList
idle
;
...
...
@@ -214,12 +212,6 @@ public:
*/
void
AddDeferred
(
DeferEvent
&
d
)
noexcept
;
/**
* Cancel a pending call to DeferEvent::RunDeferred().
* However after returning, the call may still be running.
*/
void
RemoveDeferred
(
DeferEvent
&
d
)
noexcept
;
#ifdef HAVE_THREADED_EVENT_LOOP
/**
* Schedule a call to the InjectEvent.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment