client/BackgroundCommand: infrastructure for commands running in background
This commit is contained in:
@@ -18,8 +18,10 @@
|
||||
*/
|
||||
|
||||
#include "Client.hxx"
|
||||
#include "Config.hxx"
|
||||
#include "Partition.hxx"
|
||||
#include "Instance.hxx"
|
||||
#include "BackgroundCommand.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "config.h"
|
||||
|
||||
@@ -27,6 +29,37 @@ Client::~Client() noexcept
|
||||
{
|
||||
if (FullyBufferedSocket::IsDefined())
|
||||
FullyBufferedSocket::Close();
|
||||
|
||||
if (background_command) {
|
||||
background_command->Cancel();
|
||||
background_command.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Client::SetBackgroundCommand(std::unique_ptr<BackgroundCommand> _bc) noexcept
|
||||
{
|
||||
assert(!background_command);
|
||||
assert(_bc);
|
||||
|
||||
background_command = std::move(_bc);
|
||||
|
||||
/* disable timeouts while in "idle" */
|
||||
timeout_event.Cancel();
|
||||
}
|
||||
|
||||
void
|
||||
Client::OnBackgroundCommandFinished() noexcept
|
||||
{
|
||||
assert(background_command);
|
||||
|
||||
background_command.reset();
|
||||
|
||||
/* just in case OnSocketInput() has returned
|
||||
InputResult::PAUSE meanwhile */
|
||||
ResumeInput();
|
||||
|
||||
timeout_event.Schedule(client_timeout);
|
||||
}
|
||||
|
||||
Instance &
|
||||
|
||||
Reference in New Issue
Block a user