MeVisLab Toolbox Reference
ThreadPool.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code
3
4#pragma once
5
6#include <asio/System.h>
7#include <asio/Context.h>
8
9#include <FMEThirdPartyWarningsDisable.h>
10#include <vector>
11#include <thread>
12#include <memory>
13#include <boost/asio/executor_work_guard.hpp>
14#include <FMEThirdPartyWarningsRestore.h>
15
16
17namespace asio {
18
30 {
31 public:
32
33 ThreadPool(std::shared_ptr<Context> context, const unsigned short num_threads);
34
36
37 ThreadPool(const ThreadPool&) = delete;
38
39 ThreadPool& operator=(const ThreadPool&) = delete;
40
41 private:
42
43 std::shared_ptr<Context> context;
44 typedef boost::asio::executor_work_guard<boost::asio::io_context::executor_type> BoostWorkType;
45 std::shared_ptr< BoostWorkType > work;
46
47 std::vector<std::thread> pool;
48 };
49
50}
#define ASYNCHRONOUSIO_EXPORT
Definition System.h:10
A thread pool executing an asio::Context's run method with a bunch of threads.
Definition ThreadPool.h:30
ThreadPool(const ThreadPool &)=delete
ThreadPool & operator=(const ThreadPool &)=delete
ThreadPool(std::shared_ptr< Context > context, const unsigned short num_threads)