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
0720fa87
Commit
0720fa87
authored
Jan 09, 2015
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Importer: Drops uv_mutex in favor of std::mutex.
It is not safe to use uv_cond_wait outside of v8 thread (uv loop).
parent
0add9917
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
19 deletions
+30
-19
binding.cpp
src/binding.cpp
+4
-2
sass_context_wrapper.cpp
src/sass_context_wrapper.cpp
+8
-7
sass_context_wrapper.h
src/sass_context_wrapper.h
+18
-10
No files found.
src/binding.cpp
View file @
0720fa87
...
@@ -81,12 +81,14 @@ struct Sass_Import** sass_importer(const char* file, const char* prev, void* coo
...
@@ -81,12 +81,14 @@ struct Sass_Import** sass_importer(const char* file, const char* prev, void* coo
* can run uv_async_send without a push.
* can run uv_async_send without a push.
*/
*/
std
::
unique_lock
<
std
::
mutex
>
lock
(
*
ctx_w
->
importer_mutex
);
ctx_w
->
file
=
file
?
strdup
(
file
)
:
0
;
ctx_w
->
file
=
file
?
strdup
(
file
)
:
0
;
ctx_w
->
prev
=
prev
?
strdup
(
prev
)
:
0
;
ctx_w
->
prev
=
prev
?
strdup
(
prev
)
:
0
;
ctx_w
->
async
.
data
=
(
void
*
)
ctx_w
;
ctx_w
->
async
.
data
=
(
void
*
)
ctx_w
;
uv_async_send
(
&
ctx_w
->
async
);
uv_async_send
(
&
ctx_w
->
async
);
uv_cond_wait
(
&
ctx_w
->
importer_condition_variable
,
&
ctx_w
->
importer_mutex
);
ctx_w
->
importer_condition_variable
->
wait
(
lock
);
}
}
else
{
else
{
NanScope
();
NanScope
();
...
@@ -357,7 +359,7 @@ NAN_METHOD(ImportedCallback) {
...
@@ -357,7 +359,7 @@ NAN_METHOD(ImportedCallback) {
sass_context_wrapper
*
ctx_w
=
imports_collection
[
index
];
sass_context_wrapper
*
ctx_w
=
imports_collection
[
index
];
prepare_import_results
(
returned_value
,
ctx_w
);
prepare_import_results
(
returned_value
,
ctx_w
);
uv_cond_signal
(
&
ctx_w
->
importer_condition_variable
);
ctx_w
->
importer_condition_variable
->
notify_all
(
);
if
(
try_catch
.
HasCaught
())
{
if
(
try_catch
.
HasCaught
())
{
node
::
FatalException
(
try_catch
);
node
::
FatalException
(
try_catch
);
...
...
src/sass_context_wrapper.cpp
View file @
0720fa87
...
@@ -24,8 +24,9 @@ extern "C" {
...
@@ -24,8 +24,9 @@ extern "C" {
sass_context_wrapper
*
sass_make_context_wrapper
()
{
sass_context_wrapper
*
sass_make_context_wrapper
()
{
sass_context_wrapper
*
ctx_w
=
(
sass_context_wrapper
*
)
calloc
(
1
,
sizeof
(
sass_context_wrapper
));
sass_context_wrapper
*
ctx_w
=
(
sass_context_wrapper
*
)
calloc
(
1
,
sizeof
(
sass_context_wrapper
));
uv_mutex_init
(
&
ctx_w
->
importer_mutex
);
uv_cond_init
(
&
ctx_w
->
importer_condition_variable
);
ctx_w
->
importer_mutex
=
new
std
::
mutex
();
ctx_w
->
importer_condition_variable
=
new
std
::
condition_variable
();
return
ctx_w
;
return
ctx_w
;
}
}
...
@@ -38,14 +39,14 @@ extern "C" {
...
@@ -38,14 +39,14 @@ extern "C" {
sass_delete_file_context
(
ctx_w
->
fctx
);
sass_delete_file_context
(
ctx_w
->
fctx
);
}
}
delete
ctx_w
->
success_callback
;
delete
ctx_w
->
error_callback
;
delete
ctx_w
->
importer_callback
;
delete
ctx_w
->
file
;
delete
ctx_w
->
file
;
delete
ctx_w
->
prev
;
delete
ctx_w
->
prev
;
delete
ctx_w
->
error_callback
;
delete
ctx_w
->
success_callback
;
delete
ctx_w
->
importer_callback
;
uv_mutex_destroy
(
&
ctx_w
->
importer_mutex
)
;
delete
ctx_w
->
importer_mutex
;
uv_cond_destroy
(
&
ctx_w
->
importer_condition_variable
)
;
delete
ctx_w
->
importer_condition_variable
;
NanDisposePersistent
(
ctx_w
->
result
);
NanDisposePersistent
(
ctx_w
->
result
);
...
...
src/sass_context_wrapper.h
View file @
0720fa87
#include <nan.h>
#include <nan.h>
#include <condition_variable>
#include "libsass/sass_context.h"
#include "libsass/sass_context.h"
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -12,20 +13,27 @@ extern "C" {
...
@@ -12,20 +13,27 @@ extern "C" {
void
compile_it
(
uv_work_t
*
req
);
void
compile_it
(
uv_work_t
*
req
);
struct
sass_context_wrapper
{
struct
sass_context_wrapper
{
// binding related
bool
is_sync
;
void
*
cookie
;
const
char
*
prev
;
const
char
*
file
;
std
::
mutex
*
importer_mutex
;
std
::
condition_variable
*
importer_condition_variable
;
// libsass related
Sass_Import
**
imports
;
Sass_Data_Context
*
dctx
;
Sass_Data_Context
*
dctx
;
Sass_File_Context
*
fctx
;
Sass_File_Context
*
fctx
;
Persistent
<
Object
>
result
;
uv_work_t
request
;
// libuv related
uv_mutex_t
importer_mutex
;
uv_cond_t
importer_condition_variable
;
uv_async_t
async
;
uv_async_t
async
;
const
char
*
file
;
uv_work_t
request
;
const
char
*
prev
;
void
*
cookie
;
// v8 and nan related
bool
is_sync
;
Persistent
<
Object
>
result
;
Sass_Import
**
imports
;
NanCallback
*
success_callback
;
NanCallback
*
error_callback
;
NanCallback
*
error_callback
;
NanCallback
*
success_callback
;
NanCallback
*
importer_callback
;
NanCallback
*
importer_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