-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathCaches.cpp
More file actions
52 lines (42 loc) · 1.71 KB
/
Caches.cpp
File metadata and controls
52 lines (42 loc) · 1.71 KB
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
#include "Caches.h"
#include "Constants.h"
using namespace v8;
namespace tns {
Caches::Caches(Isolate* isolate, const int& isolateId)
: isolate_(isolate), isolateId_(isolateId) {
// Set up wrapper object. This replaces v8::Externals held in a few places, and is traced by the unified heap in v8.
HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetInternalFieldCount(2);
WrapperObjectTemplate.Reset(isolate, templ);
}
Caches::~Caches() {
this->Prototypes.clear();
this->ClassPrototypes.clear();
this->CtorFuncTemplates.clear();
this->CtorFuncs.clear();
this->ProtocolCtorFuncs.clear();
this->StructConstructorFunctions.clear();
this->PrimitiveInteropTypes.clear();
this->CFunctions.clear();
this->Instances.clear();
this->StructInstances.clear();
this->PointerInstances.clear();
this->cacheBoundObjects_.clear();
}
void Caches::Remove(v8::Isolate* isolate) {
auto cache = isolate->GetData(Constants::CACHES_ISOLATE_SLOT);
isolate->SetData(Constants::CACHES_ISOLATE_SLOT, nullptr);
if (cache != nullptr) {
delete reinterpret_cast<std::shared_ptr<Caches>*>(cache);
}
}
void Caches::SetContext(Local<Context> context) {
this->context_ = std::make_shared<Persistent<Context>>(this->isolate_, context);
}
Local<Context> Caches::GetContext() {
return this->context_->Get(this->isolate_);
}
std::shared_ptr<ConcurrentMap<std::string, const Meta*>> Caches::Metadata = std::make_shared<ConcurrentMap<std::string, const Meta*>>();
std::shared_ptr<ConcurrentMap<int, std::shared_ptr<Caches::WorkerState>>> Caches::Workers = std::make_shared<ConcurrentMap<int, std::shared_ptr<Caches::WorkerState>>>();
}