2
* Copyright (C) 2015 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com>
29
explicit Locker(v8::Isolate* isolate)
31
if (v8::Locker::IsActive() && !v8::Locker::IsLocked(isolate))
33
locker_ = std::make_shared<v8::Locker>(isolate);
34
isolate_scope_ = std::make_shared<v8::Isolate::Scope>(isolate);
35
handle_scope_ = std::make_shared<v8::HandleScope>(isolate);
36
context_scope_ = std::make_shared<v8::Context::Scope>(v8::Context::New(isolate));
41
std::shared_ptr<v8::Locker> locker_;
42
std::shared_ptr<v8::Isolate::Scope> isolate_scope_;
43
std::shared_ptr<v8::HandleScope> handle_scope_;
44
std::shared_ptr<v8::Context::Scope> context_scope_;
50
explicit Unlocker(v8::Isolate* isolate)
52
if (v8::Locker::IsActive() && v8::Locker::IsLocked(isolate))
54
unlocker_ = std::make_shared<v8::Unlocker>(isolate);
59
std::shared_ptr<v8::Unlocker> unlocker_;