You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
589 B
C++
38 lines
589 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Copyright The Music Player Daemon Project
|
|
|
|
#pragma once
|
|
|
|
#include "Loop.hxx"
|
|
#include "thread/Thread.hxx"
|
|
|
|
/**
|
|
* A thread which runs an #EventLoop.
|
|
*/
|
|
class EventThread final {
|
|
EventLoop event_loop{ThreadId::Null()};
|
|
|
|
Thread thread{BIND_THIS_METHOD(Run)};
|
|
|
|
const bool realtime;
|
|
|
|
public:
|
|
explicit EventThread(bool _realtime=false)
|
|
:realtime(_realtime) {}
|
|
|
|
~EventThread() noexcept {
|
|
Stop();
|
|
}
|
|
|
|
EventLoop &GetEventLoop() noexcept {
|
|
return event_loop;
|
|
}
|
|
|
|
void Start();
|
|
|
|
void Stop() noexcept;
|
|
|
|
private:
|
|
void Run() noexcept;
|
|
};
|