diff options
Diffstat (limited to 'src/core/thread/TaskRunnerGetter.h')
-rw-r--r-- | src/core/thread/TaskRunnerGetter.h | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/core/thread/TaskRunnerGetter.h b/src/core/thread/TaskRunnerGetter.h index 80b25c3e..49ed25c0 100644 --- a/src/core/thread/TaskRunnerGetter.h +++ b/src/core/thread/TaskRunnerGetter.h @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Saturneric + * Copyright (C) 2021 Saturneric <[email protected]> * * This file is part of GpgFrontend. * @@ -19,20 +19,25 @@ * The initial version of the source code is inherited from * the gpg4usb project, which is under GPL-3.0-or-later. * - * The source code version of this software was modified and released - * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021. + * All the source code of GpgFrontend was modified and released by + * Saturneric <[email protected]> starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later * */ -#ifndef GPGFRONTEND_TASKRUNNERGETTER_H -#define GPGFRONTEND_TASKRUNNERGETTER_H +#pragma once + +#include <mutex> #include "core/GpgFrontendCore.h" -#include "core/GpgFunctionObject.h" +#include "core/function/basic/GpgFunctionObject.h" #include "core/thread/TaskRunner.h" namespace GpgFrontend::Thread { +using TaskRunnerPtr = std::shared_ptr<TaskRunner>; + class GPGFRONTEND_CORE_EXPORT TaskRunnerGetter : public GpgFrontend::SingletonFunctionObject<TaskRunnerGetter> { public: @@ -41,18 +46,21 @@ class GPGFRONTEND_CORE_EXPORT TaskRunnerGetter kTaskRunnerType_GPG, kTaskRunnerType_IO, kTaskRunnerType_Network, + kTaskRunnerType_Module, kTaskRunnerType_External_Process, }; - TaskRunnerGetter(int channel = SingletonFunctionObject::GetDefaultChannel()); + explicit TaskRunnerGetter( + int channel = SingletonFunctionObject::GetDefaultChannel()); - TaskRunner *GetTaskRunner( - TaskRunnerType runner_type = kTaskRunnerType_Default); + auto GetTaskRunner(TaskRunnerType runner_type = kTaskRunnerType_Default) + -> TaskRunnerPtr; + + void StopAllTeakRunner(); private: - std::map<TaskRunnerType, TaskRunner *> task_runners_; + std::map<TaskRunnerType, TaskRunnerPtr> task_runners_; + std::mutex task_runners_map_lock_; }; } // namespace GpgFrontend::Thread - -#endif // GPGFRONTEND_TASKRUNNERGETTER_H
\ No newline at end of file |