8000 isolate, refactor: add safe_current() method to Isolate class. · fibjs/fibjs@90e282f · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 90e282f

Browse files
committed
isolate, re 8000 factor: add safe_current() method to Isolate class.
1 parent 7bae209 commit 90e282f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

fibjs/include/Isolate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Isolate : public exlib::linkitem {
7575
static Isolate* main();
7676

7777
static Isolate* current();
78+
static Isolate* safe_current();
7879

7980
static Isolate* current(v8::Isolate* v8_isolate)
8081
{

fibjs/src/base/Isolate.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ Isolate* Isolate::current()
193193
return rt->isolate();
194194
}
195195

196+
Isolate* Isolate::safe_current()
197+
{
198+
Runtime* rt = Runtime::current();
199+
if (rt == NULL)
200+
return NULL;
201+
202+
return rt->safe_isolate();
203+
}
204+
196205
Isolate* Isolate::main()
197206
{
198207
return s_isolates.head();

0 commit comments

Comments
 (0)
0