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