1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2019-2019 Bareos GmbH & Co. KG 5 6 This program is Free Software; you can redistribute it and/or 7 modify it under the terms of version three of the GNU Affero General Public 8 License as published by the Free Software Foundation, which is 9 listed in the file LICENSE. 10 11 This program is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301, USA. 20 */ 21 22 #ifndef BAREOS_LIB_THREAD_LIST_H_ 23 #define BAREOS_LIB_THREAD_LIST_H_ 1 24 25 #include <functional> 26 #include <memory> 27 28 class ConfigurationParser; 29 class ThreadListPrivate; 30 31 class ThreadList { 32 friend class ThreadGuard; 33 34 public: 35 ThreadList(); 36 ~ThreadList(); 37 38 using ThreadHandler 39 = std::function<void*(ConfigurationParser* config, void* data)>; 40 using ShutdownCallback = std::function<void*(void* data)>; 41 42 void Init(int maximum_thread_count, 43 ThreadHandler ThreadInvokedHandler, 44 ShutdownCallback ShutdownCallback = nullptr); 45 46 bool CreateAndAddNewThread(ConfigurationParser* config, void* data); 47 bool ShutdownAndWaitForThreadsToFinish(); 48 std::size_t Size() const; 49 50 ThreadList(const ThreadList& ohter) = delete; 51 ThreadList(const ThreadList&& ohter) = delete; 52 ThreadList& operator=(const ThreadList& rhs) = delete; 53 ThreadList& operator=(const ThreadList&& rhs) = delete; 54 55 private: 56 std::unique_ptr<ThreadListPrivate> impl_; 57 }; 58 59 60 #endif /* BAREOS_LIB_THREAD_LIST_H_ */ 61