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
d380db25
Commit
d380db25
authored
Feb 04, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instance: add attribute "event_loop"
Replaces global variable "main_loop".
parent
e8938b10
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
18 deletions
+22
-18
Instance.hxx
src/Instance.hxx
+3
-0
Main.cxx
src/Main.cxx
+16
-14
Main.hxx
src/Main.hxx
+0
-2
ClientRead.cxx
src/client/ClientRead.cxx
+3
-2
No files found.
src/Instance.hxx
View file @
d380db25
...
...
@@ -34,6 +34,7 @@ class Database;
class
UpdateService
;
#endif
class
EventLoop
;
class
Error
;
class
ClientList
;
struct
Partition
;
...
...
@@ -52,6 +53,8 @@ struct Instance final
public
NeighborListener
#endif
{
EventLoop
*
event_loop
;
#ifdef ENABLE_NEIGHBOR_PLUGINS
NeighborGlue
*
neighbors
;
#endif
...
...
src/Main.cxx
View file @
d380db25
...
...
@@ -110,7 +110,6 @@ static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
static
constexpr
Domain
main_domain
(
"main"
);
ThreadId
main_thread
;
EventLoop
*
main_loop
;
Instance
*
instance
;
...
...
@@ -197,7 +196,8 @@ glue_db_init_and_load(void)
bool
is_simple
;
Error
error
;
instance
->
database
=
DatabaseGlobalInit
(
*
main_loop
,
*
instance
,
*
param
,
instance
->
database
=
DatabaseGlobalInit
(
*
instance
->
event_loop
,
*
instance
,
*
param
,
is_simple
,
error
);
if
(
instance
->
database
==
nullptr
)
FatalError
(
error
);
...
...
@@ -211,7 +211,8 @@ glue_db_init_and_load(void)
return
true
;
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
instance
->
database
;
instance
->
update
=
new
UpdateService
(
*
main_loop
,
db
,
*
instance
);
instance
->
update
=
new
UpdateService
(
*
instance
->
event_loop
,
db
,
*
instance
);
/* run database update after daemonization? */
return
db
.
FileExists
();
...
...
@@ -247,7 +248,8 @@ glue_state_file_init(Error &error)
return
!
error
.
IsDefined
();
state_file
=
new
StateFile
(
std
::
move
(
path_fs
),
*
instance
->
partition
,
*
main_loop
);
*
instance
->
partition
,
*
instance
->
event_loop
);
state_file
->
Read
();
return
true
;
}
...
...
@@ -353,7 +355,7 @@ idle_event_emitted(void)
static
void
shutdown_event_emitted
(
void
)
{
main
_loop
->
Break
();
instance
->
event
_loop
->
Break
();
}
#endif
...
...
@@ -411,9 +413,9 @@ int mpd_main(int argc, char *argv[])
}
main_thread
=
ThreadId
::
GetCurrent
();
main_loop
=
new
EventLoop
();
instance
=
new
Instance
();
instance
->
event_loop
=
new
EventLoop
();
#ifdef ENABLE_NEIGHBOR_PLUGINS
instance
->
neighbors
=
new
NeighborGlue
();
...
...
@@ -431,7 +433,7 @@ int mpd_main(int argc, char *argv[])
const
unsigned
max_clients
=
config_get_positive
(
CONF_MAX_CONN
,
10
);
instance
->
client_list
=
new
ClientList
(
max_clients
);
if
(
!
listen_global_init
(
*
main
_loop
,
error
))
{
if
(
!
listen_global_init
(
*
instance
->
event
_loop
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
...
...
@@ -439,7 +441,7 @@ int mpd_main(int argc, char *argv[])
daemonize_set_user
();
daemonize_begin
(
options
.
daemon
);
GlobalEvents
::
Initialize
(
*
main
_loop
);
GlobalEvents
::
Initialize
(
*
instance
->
event
_loop
);
GlobalEvents
::
Register
(
GlobalEvents
::
IDLE
,
idle_event_emitted
);
#ifdef WIN32
GlobalEvents
::
Register
(
GlobalEvents
::
SHUTDOWN
,
shutdown_event_emitted
);
...
...
@@ -476,7 +478,7 @@ int mpd_main(int argc, char *argv[])
initialize_decoder_and_player
();
volume_init
();
initAudioConfig
();
instance
->
partition
->
outputs
.
Configure
(
*
main
_loop
,
instance
->
partition
->
outputs
.
Configure
(
*
instance
->
event
_loop
,
instance
->
partition
->
pc
);
client_manager_init
();
replay_gain_global_init
();
...
...
@@ -492,7 +494,7 @@ int mpd_main(int argc, char *argv[])
setup_log_output
(
options
.
log_stderr
);
SignalHandlersInit
(
*
main
_loop
);
SignalHandlersInit
(
*
instance
->
event
_loop
);
io_thread_start
();
...
...
@@ -502,7 +504,7 @@ int mpd_main(int argc, char *argv[])
FatalError
(
error
);
#endif
ZeroconfInit
(
*
main
_loop
);
ZeroconfInit
(
*
instance
->
event
_loop
);
player_create
(
instance
->
partition
->
pc
);
...
...
@@ -527,7 +529,7 @@ int mpd_main(int argc, char *argv[])
#ifdef ENABLE_INOTIFY
if
(
mapper_has_music_directory
()
&&
instance
->
update
!=
nullptr
)
mpd_inotify_init
(
*
main
_loop
,
*
instance
->
update
,
mpd_inotify_init
(
*
instance
->
event
_loop
,
*
instance
->
update
,
config_get_unsigned
(
CONF_AUTO_UPDATE_DEPTH
,
G_MAXUINT
));
#else
...
...
@@ -551,7 +553,7 @@ int mpd_main(int argc, char *argv[])
SetThreadTimerSlackMS
(
100
);
/* run the main loop */
main
_loop
->
Run
();
instance
->
event
_loop
->
Run
();
#ifdef WIN32
win32_app_stopping
();
...
...
@@ -608,8 +610,8 @@ int mpd_main(int argc, char *argv[])
config_global_finish
();
io_thread_deinit
();
SignalHandlersFinish
();
delete
instance
->
event_loop
;
delete
instance
;
delete
main_loop
;
daemonize_finish
();
#ifdef WIN32
WSACleanup
();
...
...
src/Main.hxx
View file @
d380db25
...
...
@@ -26,8 +26,6 @@ struct Instance;
extern
ThreadId
main_thread
;
extern
EventLoop
*
main_loop
;
extern
Instance
*
instance
;
/**
...
...
src/client/ClientRead.cxx
View file @
d380db25
...
...
@@ -19,7 +19,8 @@
#include "config.h"
#include "ClientInternal.hxx"
#include "Main.hxx"
#include "Partition.hxx"
#include "Instance.hxx"
#include "event/Loop.hxx"
#include "util/CharUtil.hxx"
...
...
@@ -53,7 +54,7 @@ Client::OnSocketInput(void *data, size_t length)
case
CommandResult
:
:
KILL
:
Close
();
main
_loop
->
Break
();
partition
.
instance
.
event
_loop
->
Break
();
return
InputResult
::
CLOSED
;
case
CommandResult
:
:
FINISH
:
...
...
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