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
977004c3
Commit
977004c3
authored
Aug 07, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/DeferredMonitor: use EventLoop::AddIdle()
parent
fdc7d13a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
7 deletions
+16
-7
GlobalEvents.cxx
src/GlobalEvents.cxx
+5
-2
GlobalEvents.hxx
src/GlobalEvents.hxx
+3
-1
Main.cxx
src/Main.cxx
+1
-1
DeferredMonitor.cxx
src/event/DeferredMonitor.cxx
+1
-1
DeferredMonitor.hxx
src/event/DeferredMonitor.hxx
+6
-2
No files found.
src/GlobalEvents.cxx
View file @
977004c3
...
...
@@ -33,6 +33,9 @@
namespace
GlobalEvents
{
class
Monitor
final
:
public
DeferredMonitor
{
public
:
Monitor
(
EventLoop
&
_loop
)
:
DeferredMonitor
(
_loop
)
{}
protected
:
virtual
void
Run
()
override
;
};
...
...
@@ -67,9 +70,9 @@ GlobalEvents::Monitor::Run()
}
void
GlobalEvents
::
Initialize
()
GlobalEvents
::
Initialize
(
EventLoop
&
loop
)
{
monitor
.
Construct
();
monitor
.
Construct
(
loop
);
}
void
...
...
src/GlobalEvents.hxx
View file @
977004c3
...
...
@@ -29,6 +29,8 @@
#endif
#endif
class
EventLoop
;
namespace
GlobalEvents
{
enum
Event
{
/** database update was finished */
...
...
@@ -59,7 +61,7 @@ namespace GlobalEvents {
typedef
void
(
*
Handler
)();
void
Initialize
();
void
Initialize
(
EventLoop
&
loop
);
void
Deinitialize
();
...
...
src/Main.cxx
View file @
977004c3
...
...
@@ -438,7 +438,7 @@ int mpd_main(int argc, char *argv[])
daemonize_set_user
();
GlobalEvents
::
Initialize
();
GlobalEvents
::
Initialize
(
*
main_loop
);
GlobalEvents
::
Register
(
GlobalEvents
::
IDLE
,
idle_event_emitted
);
#ifdef WIN32
GlobalEvents
::
Register
(
GlobalEvents
::
SHUTDOWN
,
shutdown_event_emitted
);
...
...
src/event/DeferredMonitor.cxx
View file @
977004c3
...
...
@@ -32,7 +32,7 @@ DeferredMonitor::Cancel()
void
DeferredMonitor
::
Schedule
()
{
const
unsigned
id
=
g_idle_add
(
Callback
,
this
);
const
unsigned
id
=
loop
.
AddIdle
(
Callback
,
this
);
const
auto
old_id
=
source_id
.
exchange
(
id
);
if
(
old_id
!=
0
)
g_source_remove
(
old_id
);
...
...
src/event/DeferredMonitor.hxx
View file @
977004c3
...
...
@@ -26,15 +26,19 @@
#include <atomic>
class
EventLoop
;
/**
* Defer execution of an event into an #EventLoop.
*/
class
DeferredMonitor
{
EventLoop
&
loop
;
std
::
atomic
<
guint
>
source_id
;
public
:
DeferredMonitor
()
:
source_id
(
0
)
{}
DeferredMonitor
(
EventLoop
&
_loop
)
:
loop
(
_loop
),
source_id
(
0
)
{}
~
DeferredMonitor
()
{
Cancel
();
...
...
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