forked from ably/xdelta-async-nodejs-addon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXdeltaEncodeAsyncWorker.h
45 lines (32 loc) · 1.23 KB
/
XdeltaEncodeAsyncWorker.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
#include <map>
#include <napi.h>
#include <xdelta3.h>
#include <BaseXdeltaAsyncWorker.h>
using namespace std;
using namespace Napi;
class XdeltaEncodeAsyncWorker : public BaseXdeltaAsyncWorker
{
public:
const int64_t id;
static string New(Buffer<uint8_t> &dictionary,
Buffer<uint8_t> &target,
Buffer<uint8_t> &result,
int32_t stringMatcherType,
Function& callback,
XdeltaEncodeAsyncWorker **encoder);
static string RequestCancellation(int64_t id);
void Execute() override;
private:
static map<int64_t, XdeltaEncodeAsyncWorker *> runningEncoders;
uint8_t cancellationRequested;
int32_t stringMatcherType;
XdeltaEncodeAsyncWorker(int64_t id,
Buffer<uint8_t> &dictionary,
Buffer<uint8_t> &taget,
Buffer<uint8_t> &result,
int32_t stringMatcherType,
Function& callback);
~XdeltaEncodeAsyncWorker() override;
static int64_t GetNewEncoderId();
void RequestCancellation();
};