blob: 52d0a0e2729476ef87757fd97d984976ee751933 (
plain)
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
|
#pragma once
#include <atomic>
#include <mutex>
#include <unordered_set>
#include <vector>
#include <functional>
#include "warp.h"
#include "binaryninjaapi.h"
#include "uitypes.h"
enum WarpFetchCompletionStatus
{
KeepCallback,
RemoveCallback,
};
// Responsible for fetching data from the containers, to later be queried from the container interface.
class WarpFetcher
{
LoggerRef m_logger;
std::mutex m_requestMutex;
std::vector<FunctionRef> m_pendingRequests;
std::unordered_set<Warp::FunctionGUID> m_processedGuids;
// List of callbacks to call when done fetching data, assume that others are using this as well.
std::vector<std::function<WarpFetchCompletionStatus()>> m_completionCallbacks;
public:
explicit WarpFetcher();
// The global fetcher instance, this is used for the fetch dialog and the sidebar.
static std::shared_ptr<WarpFetcher> Global();
std::atomic<bool> m_requestInProgress = false;
void AddCompletionCallback(std::function<WarpFetchCompletionStatus()> cb)
{
std::lock_guard<std::mutex> lock(m_requestMutex);
m_completionCallbacks.push_back(std::move(cb));
}
void AddPendingFunction(const FunctionRef& func);
void FetchPendingFunctions(const std::vector<Warp::SourceTag>& allowedTags);
void ClearProcessed();
private:
std::vector<FunctionRef> FlushPendingFunctions();
void ExecuteCompletionCallback();
};
|