Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
292e1ba5
Commit
292e1ba5
authored
Nov 21, 2014
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Importer-cb: Adds lock to acquire v8 main thread.
parent
cbcacc24
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
binding.cpp
src/binding.cpp
+12
-3
No files found.
src/binding.cpp
View file @
292e1ba5
#include <mutex>
#include <nan.h>
#include "sass_context_wrapper.h"
...
...
@@ -12,9 +13,12 @@ char* CreateString(Local<Value> value) {
return
str
;
}
uv_async_t
async
;
static
std
::
mutex
importer_mutex
;
void
dispatched_async_uv_callback
(
uv_async_t
*
req
){
std
::
unique_lock
<
std
::
mutex
>
v8_lock
(
importer_mutex
);
v8_lock
.
lock
();
//importer_mutex.lock();
NanScope
();
TryCatch
try_catch
;
...
...
@@ -57,6 +61,8 @@ void dispatched_async_uv_callback(uv_async_t *req){
bag
->
incs
[
0
]
=
sass_make_import_entry
(
bag
->
file
,
0
,
0
);
}
v8_lock
.
unlock
();
//importer_mutex.unlock();
if
(
try_catch
.
HasCaught
())
{
node
::
FatalException
(
try_catch
);
}
...
...
@@ -64,16 +70,20 @@ void dispatched_async_uv_callback(uv_async_t *req){
struct
Sass_Import
**
sass_importer
(
const
char
*
file
,
void
*
cookie
)
{
std
::
try_lock
(
importer_mutex
);
import_bag
*
bag
=
(
import_bag
*
)
calloc
(
1
,
sizeof
(
import_bag
));
bag
->
cookie
=
cookie
;
bag
->
file
=
file
;
uv_async_t
async
;
uv_async_init
(
uv_default_loop
(),
&
async
,
(
uv_async_cb
)
dispatched_async_uv_callback
);
async
.
data
=
(
void
*
)
bag
;
uv_async_send
(
&
async
);
// Dispatch immediately
uv_run
(
async
.
loop
,
UV_RUN_DEFAULT
);
//
uv_run(async.loop, UV_RUN_DEFAULT);
Sass_Import
**
import
=
bag
->
incs
;
...
...
@@ -115,7 +125,6 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
if
(
!
importer_callback
->
IsUndefined
()){
sass_option_set_importer
(
sass_options
,
sass_make_importer
(
sass_importer
,
ctx_w
->
importer_callback
));
uv_async_init
(
uv_default_loop
(),
&
async
,
(
uv_async_cb
)
dispatched_async_uv_callback
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment