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
ce68701c
Commit
ce68701c
authored
Jan 29, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/Loop: add flag "dead"
parent
6ea2cb36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
Loop.cxx
src/event/Loop.cxx
+9
-2
Loop.hxx
src/event/Loop.hxx
+9
-0
No files found.
src/event/Loop.cxx
View file @
ce68701c
...
...
@@ -25,7 +25,9 @@
#include "util/ScopeExit.hxx"
EventLoop
::
EventLoop
(
ThreadId
_thread
)
:
SocketMonitor
(
*
this
),
quit
(
false
),
thread
(
_thread
)
:
SocketMonitor
(
*
this
),
quit
(
false
),
dead
(
false
),
thread
(
_thread
)
{
SocketMonitor
::
Open
(
SocketDescriptor
(
wake_fd
.
Get
()));
}
...
...
@@ -142,10 +144,14 @@ EventLoop::Run() noexcept
assert
(
IsInside
());
assert
(
!
quit
);
assert
(
!
dead
);
assert
(
busy
);
SocketMonitor
::
Schedule
(
SocketMonitor
::
READ
);
AtScopeExit
(
this
)
{
SocketMonitor
::
Cancel
();
};
AtScopeExit
(
this
)
{
dead
=
true
;
SocketMonitor
::
Cancel
();
};
do
{
now
=
std
::
chrono
::
steady_clock
::
now
();
...
...
@@ -210,6 +216,7 @@ EventLoop::Run() noexcept
}
while
(
!
quit
);
#ifndef NDEBUG
assert
(
!
dead
);
assert
(
busy
);
assert
(
thread
.
IsInside
());
#endif
...
...
src/event/Loop.hxx
View file @
ce68701c
...
...
@@ -89,6 +89,11 @@ class EventLoop final : SocketMonitor
std
::
atomic_bool
quit
;
/**
* If this is true, then Run() has returned.
*/
std
::
atomic_bool
dead
;
/**
* True when the object has been modified and another check is
* necessary before going to sleep via PollGroup::ReadEvents().
*/
...
...
@@ -199,6 +204,10 @@ private:
bool
OnSocketReady
(
unsigned
flags
)
noexcept
override
;
public
:
gcc_pure
bool
IsDead
()
const
noexcept
{
return
dead
;
}
/**
* Are we currently running inside this EventLoop's thread?
...
...
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