/
WorkerPool.h
28 lines (27 loc) · 1.02 KB
/
WorkerPool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef SORBET_WORKERPOOL_H
#define SORBET_WORKERPOOL_H
#include "common/common.h"
#include "spdlog/spdlog.h"
namespace spd = spdlog;
namespace sorbet {
class WorkerPool {
public:
inline static constexpr std::chrono::milliseconds BLOCK_INTERVAL() {
using namespace std::chrono_literals;
// NOTE: This value materially impacts IDE responsiveness during typechecking; the typechecking thread wakes up
// at this interval and checks if it should do other work.
return 20ms;
}
using Task = std::function<void()>;
static std::unique_ptr<WorkerPool> create(int size, spd::logger &logger);
virtual void multiplexJob(std::string_view taskName, Task t) = 0;
virtual ~WorkerPool() = 0;
virtual int size() = 0;
WorkerPool() = default;
WorkerPool(WorkerPool &) = delete;
WorkerPool(const WorkerPool &) = delete;
WorkerPool &operator=(WorkerPool &&) = delete;
WorkerPool &operator=(const WorkerPool &) = delete;
};
}; // namespace sorbet
#endif // SORBET_WORKERPOOL_H