Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
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-sqlite3
Commits
1b5aa3a7
Commit
1b5aa3a7
authored
Jun 23, 2018
by
Ryan Petrich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for node 10.5's --experimental-worker threading support
parent
5278b2b0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
14 deletions
+18
-14
async.h
src/async.h
+2
-2
database.cc
src/database.cc
+8
-8
database.h
src/database.h
+5
-1
macros.h
src/macros.h
+1
-1
statement.cc
src/statement.cc
+1
-1
statement.h
src/statement.h
+1
-1
No files found.
src/async.h
View file @
1b5aa3a7
...
@@ -22,11 +22,11 @@ public:
...
@@ -22,11 +22,11 @@ public:
Parent
*
parent
;
Parent
*
parent
;
public
:
public
:
Async
(
Parent
*
parent_
,
Callback
cb_
)
Async
(
uv_loop_t
*
loop_
,
Parent
*
parent_
,
Callback
cb_
)
:
callback
(
cb_
),
parent
(
parent_
)
{
:
callback
(
cb_
),
parent
(
parent_
)
{
watcher
.
data
=
this
;
watcher
.
data
=
this
;
NODE_SQLITE3_MUTEX_INIT
NODE_SQLITE3_MUTEX_INIT
uv_async_init
(
uv_default_loop
()
,
&
watcher
,
reinterpret_cast
<
uv_async_cb
>
(
listener
));
uv_async_init
(
loop_
,
&
watcher
,
reinterpret_cast
<
uv_async_cb
>
(
listener
));
}
}
static
void
listener
(
uv_async_t
*
handle
,
int
status
)
{
static
void
listener
(
uv_async_t
*
handle
,
int
status
)
{
...
...
src/database.cc
View file @
1b5aa3a7
...
@@ -127,7 +127,7 @@ NAN_METHOD(Database::New) {
...
@@ -127,7 +127,7 @@ NAN_METHOD(Database::New) {
callback
=
Local
<
Function
>::
Cast
(
info
[
pos
++
]);
callback
=
Local
<
Function
>::
Cast
(
info
[
pos
++
]);
}
}
Database
*
db
=
new
Database
();
Database
*
db
=
new
Database
(
node
::
GetCurrentEventLoop
(
info
.
GetIsolate
())
);
db
->
Wrap
(
info
.
This
());
db
->
Wrap
(
info
.
This
());
Nan
::
ForceSet
(
info
.
This
(),
Nan
::
New
(
"filename"
).
ToLocalChecked
(),
info
[
0
].
As
<
String
>
(),
ReadOnly
);
Nan
::
ForceSet
(
info
.
This
(),
Nan
::
New
(
"filename"
).
ToLocalChecked
(),
info
[
0
].
As
<
String
>
(),
ReadOnly
);
...
@@ -141,7 +141,7 @@ NAN_METHOD(Database::New) {
...
@@ -141,7 +141,7 @@ NAN_METHOD(Database::New) {
}
}
void
Database
::
Work_BeginOpen
(
Baton
*
baton
)
{
void
Database
::
Work_BeginOpen
(
Baton
*
baton
)
{
int
status
=
uv_queue_work
(
uv_default_loop
()
,
int
status
=
uv_queue_work
(
baton
->
db
->
loop
,
&
baton
->
request
,
Work_Open
,
(
uv_after_work_cb
)
Work_AfterOpen
);
&
baton
->
request
,
Work_Open
,
(
uv_after_work_cb
)
Work_AfterOpen
);
assert
(
status
==
0
);
assert
(
status
==
0
);
}
}
...
@@ -227,7 +227,7 @@ void Database::Work_BeginClose(Baton* baton) {
...
@@ -227,7 +227,7 @@ void Database::Work_BeginClose(Baton* baton) {
baton
->
db
->
RemoveCallbacks
();
baton
->
db
->
RemoveCallbacks
();
baton
->
db
->
closing
=
true
;
baton
->
db
->
closing
=
true
;
int
status
=
uv_queue_work
(
uv_default_loop
()
,
int
status
=
uv_queue_work
(
baton
->
db
->
loop
,
&
baton
->
request
,
Work_Close
,
(
uv_after_work_cb
)
Work_AfterClose
);
&
baton
->
request
,
Work_Close
,
(
uv_after_work_cb
)
Work_AfterClose
);
assert
(
status
==
0
);
assert
(
status
==
0
);
}
}
...
@@ -388,7 +388,7 @@ void Database::RegisterTraceCallback(Baton* baton) {
...
@@ -388,7 +388,7 @@ void Database::RegisterTraceCallback(Baton* baton) {
if
(
db
->
debug_trace
==
NULL
)
{
if
(
db
->
debug_trace
==
NULL
)
{
// Add it.
// Add it.
db
->
debug_trace
=
new
AsyncTrace
(
db
,
TraceCallback
);
db
->
debug_trace
=
new
AsyncTrace
(
db
->
loop
,
db
,
TraceCallback
);
sqlite3_trace
(
db
->
_handle
,
TraceCallback
,
db
);
sqlite3_trace
(
db
->
_handle
,
TraceCallback
,
db
);
}
}
else
{
else
{
...
@@ -426,7 +426,7 @@ void Database::RegisterProfileCallback(Baton* baton) {
...
@@ -426,7 +426,7 @@ void Database::RegisterProfileCallback(Baton* baton) {
if
(
db
->
debug_profile
==
NULL
)
{
if
(
db
->
debug_profile
==
NULL
)
{
// Add it.
// Add it.
db
->
debug_profile
=
new
AsyncProfile
(
db
,
ProfileCallback
);
db
->
debug_profile
=
new
AsyncProfile
(
db
->
loop
,
db
,
ProfileCallback
);
sqlite3_profile
(
db
->
_handle
,
ProfileCallback
,
db
);
sqlite3_profile
(
db
->
_handle
,
ProfileCallback
,
db
);
}
}
else
{
else
{
...
@@ -467,7 +467,7 @@ void Database::RegisterUpdateCallback(Baton* baton) {
...
@@ -467,7 +467,7 @@ void Database::RegisterUpdateCallback(Baton* baton) {
if
(
db
->
update_event
==
NULL
)
{
if
(
db
->
update_event
==
NULL
)
{
// Add it.
// Add it.
db
->
update_event
=
new
AsyncUpdate
(
db
,
UpdateCallback
);
db
->
update_event
=
new
AsyncUpdate
(
db
->
loop
,
db
,
UpdateCallback
);
sqlite3_update_hook
(
db
->
_handle
,
UpdateCallback
,
db
);
sqlite3_update_hook
(
db
->
_handle
,
UpdateCallback
,
db
);
}
}
else
{
else
{
...
@@ -522,7 +522,7 @@ void Database::Work_BeginExec(Baton* baton) {
...
@@ -522,7 +522,7 @@ void Database::Work_BeginExec(Baton* baton) {
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
_handle
);
assert
(
baton
->
db
->
_handle
);
assert
(
baton
->
db
->
pending
==
0
);
assert
(
baton
->
db
->
pending
==
0
);
int
status
=
uv_queue_work
(
uv_default_loop
()
,
int
status
=
uv_queue_work
(
baton
->
db
->
loop
,
&
baton
->
request
,
Work_Exec
,
(
uv_after_work_cb
)
Work_AfterExec
);
&
baton
->
request
,
Work_Exec
,
(
uv_after_work_cb
)
Work_AfterExec
);
assert
(
status
==
0
);
assert
(
status
==
0
);
}
}
...
@@ -622,7 +622,7 @@ void Database::Work_BeginLoadExtension(Baton* baton) {
...
@@ -622,7 +622,7 @@ void Database::Work_BeginLoadExtension(Baton* baton) {
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
_handle
);
assert
(
baton
->
db
->
_handle
);
assert
(
baton
->
db
->
pending
==
0
);
assert
(
baton
->
db
->
pending
==
0
);
int
status
=
uv_queue_work
(
uv_default_loop
()
,
int
status
=
uv_queue_work
(
baton
->
db
->
loop
,
&
baton
->
request
,
Work_LoadExtension
,
reinterpret_cast
<
uv_after_work_cb
>
(
Work_AfterLoadExtension
));
&
baton
->
request
,
Work_LoadExtension
,
reinterpret_cast
<
uv_after_work_cb
>
(
Work_AfterLoadExtension
));
assert
(
status
==
0
);
assert
(
status
==
0
);
}
}
...
...
src/database.h
View file @
1b5aa3a7
...
@@ -100,8 +100,9 @@ public:
...
@@ -100,8 +100,9 @@ public:
friend
class
Statement
;
friend
class
Statement
;
protected
:
protected
:
Database
()
:
Nan
::
ObjectWrap
(),
Database
(
uv_loop_t
*
loop_
)
:
Nan
::
ObjectWrap
(),
_handle
(
NULL
),
_handle
(
NULL
),
loop
(
loop_
),
open
(
false
),
open
(
false
),
closing
(
false
),
closing
(
false
),
locked
(
false
),
locked
(
false
),
...
@@ -172,7 +173,10 @@ protected:
...
@@ -172,7 +173,10 @@ protected:
protected
:
protected
:
sqlite3
*
_handle
;
sqlite3
*
_handle
;
public
:
uv_loop_t
*
loop
;
protected
:
bool
open
;
bool
open
;
bool
closing
;
bool
closing
;
bool
locked
;
bool
locked
;
...
...
src/macros.h
View file @
1b5aa3a7
...
@@ -122,7 +122,7 @@ const char* sqlite_authorizer_string(int type);
...
@@ -122,7 +122,7 @@ const char* sqlite_authorizer_string(int type);
assert(baton->stmt->prepared); \
assert(baton->stmt->prepared); \
baton->stmt->locked = true; \
baton->stmt->locked = true; \
baton->stmt->db->pending++; \
baton->stmt->db->pending++; \
int status = uv_queue_work(
uv_default_loop(),
\
int status = uv_queue_work(
baton->stmt->db->loop,
\
&baton->request, \
&baton->request, \
Work_##type, reinterpret_cast<uv_after_work_cb>(Work_After##type)); \
Work_##type, reinterpret_cast<uv_after_work_cb>(Work_After##type)); \
assert(status == 0);
assert(status == 0);
...
...
src/statement.cc
View file @
1b5aa3a7
...
@@ -115,7 +115,7 @@ NAN_METHOD(Statement::New) {
...
@@ -115,7 +115,7 @@ NAN_METHOD(Statement::New) {
void
Statement
::
Work_BeginPrepare
(
Database
::
Baton
*
baton
)
{
void
Statement
::
Work_BeginPrepare
(
Database
::
Baton
*
baton
)
{
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
open
);
baton
->
db
->
pending
++
;
baton
->
db
->
pending
++
;
int
status
=
uv_queue_work
(
uv_default_loop
()
,
int
status
=
uv_queue_work
(
baton
->
db
->
loop
,
&
baton
->
request
,
Work_Prepare
,
(
uv_after_work_cb
)
Work_AfterPrepare
);
&
baton
->
request
,
Work_Prepare
,
(
uv_after_work_cb
)
Work_AfterPrepare
);
assert
(
status
==
0
);
assert
(
status
==
0
);
}
}
...
...
src/statement.h
View file @
1b5aa3a7
...
@@ -174,7 +174,7 @@ public:
...
@@ -174,7 +174,7 @@ public:
watcher
.
data
=
this
;
watcher
.
data
=
this
;
NODE_SQLITE3_MUTEX_INIT
NODE_SQLITE3_MUTEX_INIT
stmt
->
Ref
();
stmt
->
Ref
();
uv_async_init
(
uv_default_loop
()
,
&
watcher
,
async_cb
);
uv_async_init
(
stmt
->
db
->
loop
,
&
watcher
,
async_cb
);
}
}
~
Async
()
{
~
Async
()
{
...
...
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