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
61b938d6
Commit
61b938d6
authored
Jan 09, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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.
parent
0c34555b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
IdleMonitor.cxx
src/event/IdleMonitor.cxx
+1
-1
Loop.cxx
src/event/Loop.cxx
+13
-4
Loop.hxx
src/event/Loop.hxx
+15
-0
No files found.
src/event/IdleMonitor.cxx
View file @
61b938d6
...
...
@@ -38,7 +38,7 @@ IdleMonitor::Cancel()
void
IdleMonitor
::
Schedule
()
{
assert
(
loop
.
IsInside
());
assert
(
loop
.
IsInside
OrVirgin
());
if
(
IsActive
())
/* already scheduled */
...
...
src/event/Loop.cxx
View file @
61b938d6
...
...
@@ -32,6 +32,9 @@ EventLoop::EventLoop(Default)
:
SocketMonitor
(
*
this
),
now_ms
(
::
MonotonicClockMS
()),
quit
(
false
),
busy
(
true
),
#ifndef NDEBUG
virgin
(
true
),
#endif
thread
(
ThreadId
::
Null
())
{
SocketMonitor
::
Open
(
wake_fd
.
Get
());
...
...
@@ -58,7 +61,7 @@ EventLoop::Break()
bool
EventLoop
::
Abandon
(
int
_fd
,
SocketMonitor
&
m
)
{
assert
(
IsInside
());
assert
(
IsInside
OrVirgin
());
poll_result
.
Clear
(
&
m
);
return
poll_group
.
Abandon
(
_fd
);
...
...
@@ -76,7 +79,7 @@ EventLoop::RemoveFD(int _fd, SocketMonitor &m)
void
EventLoop
::
AddIdle
(
IdleMonitor
&
i
)
{
assert
(
IsInside
());
assert
(
IsInside
OrVirgin
());
assert
(
std
::
find
(
idle
.
begin
(),
idle
.
end
(),
&
i
)
==
idle
.
end
());
idle
.
push_back
(
&
i
);
...
...
@@ -86,7 +89,7 @@ EventLoop::AddIdle(IdleMonitor &i)
void
EventLoop
::
RemoveIdle
(
IdleMonitor
&
i
)
{
assert
(
IsInside
());
assert
(
IsInside
OrVirgin
());
auto
it
=
std
::
find
(
idle
.
begin
(),
idle
.
end
(),
&
i
);
assert
(
it
!=
idle
.
end
());
...
...
@@ -97,7 +100,7 @@ EventLoop::RemoveIdle(IdleMonitor &i)
void
EventLoop
::
AddTimer
(
TimeoutMonitor
&
t
,
unsigned
ms
)
{
assert
(
IsInside
());
assert
(
IsInside
OrVirgin
());
timers
.
insert
(
TimerRecord
(
t
,
now_ms
+
ms
));
again
=
true
;
...
...
@@ -120,6 +123,12 @@ void
EventLoop
::
Run
()
{
assert
(
thread
.
IsNull
());
assert
(
virgin
);
#ifndef NDEBUG
virgin
=
false
;
#endif
thread
=
ThreadId
::
GetCurrent
();
assert
(
!
quit
);
...
...
src/event/Loop.hxx
View file @
61b938d6
...
...
@@ -98,6 +98,14 @@ class EventLoop final : SocketMonitor
*/
bool
busy
;
#ifndef NDEBUG
/**
* True if Run() was never called. This is used for assert()
* calls.
*/
bool
virgin
;
#endif
PollGroup
poll_group
;
PollResult
poll_result
;
...
...
@@ -200,6 +208,13 @@ public:
#ifndef NDEBUG
gcc_pure
bool
IsInsideOrVirgin
()
const
{
return
virgin
||
IsInside
();
}
#endif
#ifndef NDEBUG
gcc_pure
bool
IsInsideOrNull
()
const
{
return
thread
.
IsNull
()
||
thread
.
IsInside
();
}
...
...
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