diff options
| -rw-r--r-- | src/main.cpp | 10 | ||||
| -rw-r--r-- | src/stream.cpp | 4 | ||||
| -rw-r--r-- | src/stream.hpp | 4 |
3 files changed, 8 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index 88b56cd..3c8f5e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,10 +114,14 @@ int main(int argc, char *argv[]) { client.run(); - std::thread timer_thread(bot::create_timer_thread, &client, &cfg); - timer_thread.join(); + std::vector<std::thread> threads; + threads.push_back(std::thread(bot::create_timer_thread, &client, &cfg)); + threads.push_back(std::thread(&bot::stream::StreamListenerClient::run, + &stream_listener_client)); - stream_listener_client.run_thread(); + for (auto &thread : threads) { + thread.join(); + } return 0; } diff --git a/src/stream.cpp b/src/stream.cpp index c886446..6e48fb8 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -34,10 +34,6 @@ namespace bot::stream { this->online_ids.erase(y); } } - void StreamListenerClient::run_thread() { - std::thread t(&bot::stream::StreamListenerClient::run, this); - t.join(); - } void StreamListenerClient::run() { while (true) { this->update_channel_ids(); diff --git a/src/stream.hpp b/src/stream.hpp index 28fe0e3..73313ed 100644 --- a/src/stream.hpp +++ b/src/stream.hpp @@ -20,13 +20,11 @@ namespace bot::stream { configuration(configuration){}; ~StreamListenerClient() = default; - void run_thread(); - + void run(); void listen_channel(const int &id); void unlisten_channel(const int &id); private: - void run(); void check(); void handler(const schemas::EventType &type, const api::twitch::schemas::Stream &stream); |
