Skip to content

Commit

Permalink
event/Thread: start the thread in the constructor
Browse files Browse the repository at this point in the history
This is the proper fix for the e309941 regression; see
commit abc8420
  • Loading branch information
MaxKellermann committed Jan 30, 2025
1 parent ae112fe commit b49cfe9
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 22 deletions.
3 changes: 0 additions & 3 deletions src/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ MainConfigured(const CommandLineOptions &options,
Instance instance;
global_instance = &instance;

instance.io_thread.Start();
instance.rtio_thread.Start();

#ifdef ENABLE_NEIGHBOR_PLUGINS
instance.neighbors = std::make_unique<NeighborGlue>();
instance.neighbors->Init(raw_config,
Expand Down
6 changes: 4 additions & 2 deletions src/event/Thread.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class EventThread final {
public:
explicit EventThread(bool _realtime=false)
:event_loop(ThreadId::Null()), thread(BIND_THIS_METHOD(Run)),
realtime(_realtime) {}
realtime(_realtime) {
Start();
}

~EventThread() noexcept {
Stop();
Expand All @@ -30,11 +32,11 @@ public:
return event_loop;
}

private:
void Start();

void Stop() noexcept;

private:
void Run() noexcept;
};

Expand Down
6 changes: 0 additions & 6 deletions test/DumpDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ class GlobalInit {
EventThread io_thread;

public:
GlobalInit() {
io_thread.Start();
}

~GlobalInit() = default;

EventLoop &GetEventLoop() {
return io_thread.GetEventLoop();
}
Expand Down
1 change: 0 additions & 1 deletion test/DumpOgg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ try {
const char *path = argv[1];

EventThread io_thread;
io_thread.Start();

const ScopeInputPluginsInit input_plugins_init(ConfigData(),
io_thread.GetEventLoop());
Expand Down
2 changes: 0 additions & 2 deletions test/RunChromaprint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class GlobalInit {
input_plugins_init(config, io_thread.GetEventLoop()),
decoder_plugins_init(config)
{
io_thread.Start();

pcm_convert_global_init(config);
}
};
Expand Down
1 change: 0 additions & 1 deletion test/dump_playlist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ try {
const auto config = AutoLoadConfigFile(config_path);

EventThread io_thread;
io_thread.Start();

const ScopeInputPluginsInit input_plugins_init(config, io_thread.GetEventLoop());
const ScopePlaylistPluginsInit playlist_plugins_init(config);
Expand Down
1 change: 0 additions & 1 deletion test/dump_text_file.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class GlobalInit {
explicit GlobalInit(Path config_path)
:config(AutoLoadConfigFile(config_path))
{
io_thread.Start();
}
};

Expand Down
1 change: 0 additions & 1 deletion test/read_tags.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ try {
const char *path = argv[2];

EventThread io_thread;
io_thread.Start();

const ScopeInputPluginsInit input_plugins_init(ConfigData(),
io_thread.GetEventLoop());
Expand Down
1 change: 0 additions & 1 deletion test/run_decoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class GlobalInit {
input_plugins_init(config, io_thread.GetEventLoop()),
decoder_plugins_init(config)
{
io_thread.Start();
}
};

Expand Down
1 change: 0 additions & 1 deletion test/run_input.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class GlobalInit {
explicit GlobalInit(Path config_path)
:config(AutoLoadConfigFile(config_path))
{
io_thread.Start();
}
};

Expand Down
1 change: 0 additions & 1 deletion test/run_output.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ try {
const auto config = AutoLoadConfigFile(c.config_path);

EventThread io_thread;
io_thread.Start();

/* initialize the audio output */

Expand Down
1 change: 0 additions & 1 deletion test/run_storage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class GlobalInit {
GlobalInit(Path config_path)
:config(AutoLoadConfigFile(config_path))
{
io_thread.Start();
}

EventLoop &GetEventLoop() noexcept {
Expand Down
1 change: 0 additions & 1 deletion test/visit_archive.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class GlobalInit {
explicit GlobalInit(Path config_path)
:config(AutoLoadConfigFile(config_path))
{
io_thread.Start();
}
};

Expand Down

0 comments on commit b49cfe9

Please sign in to comment.