diff options
| author | Nat Goodspeed <nat@lindenlab.com> | 2021-11-04 15:40:30 -0400 |
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2021-11-04 15:40:30 -0400 |
| commit | 7a5b92199598be0fc5a2702d071afda06e6ae59f (patch) | |
| tree | 989dbe8554b42f6c06038b01de1ea9686ab42434 /indra/llcommon/threadpool.h | |
| parent | 3faba7515c757ca3183522bd017c0f76d9c4581c (diff) | |
| parent | 8b16ecb9cfb4917fe38e4e5b0e4f40a23dd4ffbf (diff) | |
SL-16202: Merge branch 'sl-16220' into glthread
Diffstat (limited to 'indra/llcommon/threadpool.h')
| -rw-r--r-- | indra/llcommon/threadpool.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h new file mode 100644 index 0000000000..8f3c8514b5 --- /dev/null +++ b/indra/llcommon/threadpool.h @@ -0,0 +1,46 @@ +/** + * @file threadpool.h + * @author Nat Goodspeed + * @date 2021-10-21 + * @brief ThreadPool configures a WorkQueue along with a pool of threads to + * service it. + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Copyright (c) 2021, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_THREADPOOL_H) +#define LL_THREADPOOL_H + +#include "workqueue.h" +#include <string> +#include <thread> +#include <utility> // std::pair +#include <vector> + +namespace LL +{ + + class ThreadPool + { + public: + /** + * Pass ThreadPool a string name. This can be used to look up the + * relevant WorkQueue. + */ + ThreadPool(const std::string& name, size_t threads=1); + ~ThreadPool(); + void close(); + + private: + void run(const std::string& name); + + WorkQueue mQueue; + std::string mName; + std::vector<std::pair<std::string, std::thread>> mThreads; + }; + +} // namespace LL + +#endif /* ! defined(LL_THREADPOOL_H) */ |
