-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrejit_work_offloader.h
56 lines (40 loc) · 1.14 KB
/
rejit_work_offloader.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef OTEL_CLR_PROFILER_REJIT_WORK_OFFLOADER_H_
#define OTEL_CLR_PROFILER_REJIT_WORK_OFFLOADER_H_
#include <atomic>
#include <future>
#include <mutex>
#include <shared_mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "cor.h"
#include "corprof.h"
#include "module_metadata.h"
namespace trace
{
struct RejitWorkItem
{
const bool terminating = false;
const std::function<void()> func = nullptr;
RejitWorkItem();
RejitWorkItem(std::function<void()>&& func);
static std::unique_ptr<RejitWorkItem> CreateTerminatingWorkItem();
};
class RejitWorkOffloader
{
private:
ICorProfilerInfo7* m_profilerInfo;
std::unique_ptr<UniqueBlockingQueue<RejitWorkItem>> m_offloader_queue;
std::unique_ptr<std::thread> m_offloader_queue_thread;
static void EnqueueThreadLoop(RejitWorkOffloader* offloader);
public:
RejitWorkOffloader(ICorProfilerInfo7* pInfo);
void Enqueue(std::unique_ptr<RejitWorkItem>&& item);
bool WaitForTermination();
};
} // namespace trace
#endif // OTEL_CLR_PROFILER_REJIT_WORK_OFFLOADER_H_