player/Control: add "occupied" flag to skip REFRESH

Reduces main thread contention.  Avoids blocking the main thread in
"status" commands.
This commit is contained in:
Max Kellermann
2017-12-20 20:27:19 +01:00
parent 994c9a01e3
commit a431274b32
3 changed files with 30 additions and 1 deletions

View File

@@ -44,6 +44,7 @@ PlayerControl::PlayerControl(PlayerListener &_listener,
PlayerControl::~PlayerControl() noexcept
{
assert(!occupied);
}
bool
@@ -155,7 +156,8 @@ PlayerControl::LockGetStatus() noexcept
player_status status;
const std::lock_guard<Mutex> protect(mutex);
SynchronousCommand(PlayerCommand::REFRESH);
if (!occupied)
SynchronousCommand(PlayerCommand::REFRESH);
status.state = state;