Skip to content

Commit 113be5a

Browse files
authored
Merge pull request #1009 from mapbox/revert-1007-experimental-worker
Revert "Add support for running inside a node 10.5 worker_thread"
2 parents 36ec8cf + ffc1c21 commit 113be5a

File tree

8 files changed

+15
-38
lines changed

8 files changed

+15
-38
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
"prepublishOnly": "npm ls",
5151
"install": "node-pre-gyp install --fallback-to-build",
5252
"pretest": "node test/support/createdb.js",
53-
"test": "mocha -R spec --timeout 480000",
54-
"test:worker": "node --experimental-worker scripts/mocha-as-worker.js -R spec --timeout 480000"
53+
"test": "mocha -R spec --timeout 480000"
5554
},
5655
"license": "BSD-3-Clause",
5756
"keywords": [

scripts/mocha-as-worker.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/async.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ template <class Item, class Parent> class Async {
2222
Parent* parent;
2323

2424
public:
25-
Async(uv_loop_t* loop_, Parent* parent_, Callback cb_)
25+
Async(Parent* parent_, Callback cb_)
2626
: callback(cb_), parent(parent_) {
2727
watcher.data = this;
2828
NODE_SQLITE3_MUTEX_INIT
29-
uv_async_init(loop_, &watcher, reinterpret_cast<uv_async_cb>(listener));
29+
uv_async_init(uv_default_loop(), &watcher, reinterpret_cast<uv_async_cb>(listener));
3030
}
3131

3232
static void listener(uv_async_t* handle, int status) {

src/database.cc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,7 @@ NAN_METHOD(Database::New) {
127127
callback = Local<Function>::Cast(info[pos++]);
128128
}
129129

130-
#if NODE_MODULE_VERSION > NODE_9_0_MODULE_VERSION
131-
uv_loop_t* loop = node::GetCurrentEventLoop(info.GetIsolate());
132-
#else
133-
uv_loop_t* loop = uv_default_loop();
134-
#endif
135-
Database* db = new Database(loop);
130+
Database* db = new Database();
136131
db->Wrap(info.This());
137132

138133
Nan::ForceSet(info.This(), Nan::New("filename").ToLocalChecked(), info[0].As<String>(), ReadOnly);
@@ -146,7 +141,7 @@ NAN_METHOD(Database::New) {
146141
}
147142

148143
void Database::Work_BeginOpen(Baton* baton) {
149-
int status = uv_queue_work(baton->db->loop,
144+
int status = uv_queue_work(uv_default_loop(),
150145
&baton->request, Work_Open, (uv_after_work_cb)Work_AfterOpen);
151146
assert(status == 0);
152147
}
@@ -232,7 +227,7 @@ void Database::Work_BeginClose(Baton* baton) {
232227
baton->db->RemoveCallbacks();
233228
baton->db->closing = true;
234229

235-
int status = uv_queue_work(baton->db->loop,
230+
int status = uv_queue_work(uv_default_loop(),
236231
&baton->request, Work_Close, (uv_after_work_cb)Work_AfterClose);
237232
assert(status == 0);
238233
}
@@ -393,7 +388,7 @@ void Database::RegisterTraceCallback(Baton* baton) {
393388

394389
if (db->debug_trace == NULL) {
395390
// Add it.
396-
db->debug_trace = new AsyncTrace(db->loop, db, TraceCallback);
391+
db->debug_trace = new AsyncTrace(db, TraceCallback);
397392
sqlite3_trace(db->_handle, TraceCallback, db);
398393
}
399394
else {
@@ -431,7 +426,7 @@ void Database::RegisterProfileCallback(Baton* baton) {
431426

432427
if (db->debug_profile == NULL) {
433428
// Add it.
434-
db->debug_profile = new AsyncProfile(db->loop, db, ProfileCallback);
429+
db->debug_profile = new AsyncProfile(db, ProfileCallback);
435430
sqlite3_profile(db->_handle, ProfileCallback, db);
436431
}
437432
else {
@@ -472,7 +467,7 @@ void Database::RegisterUpdateCallback(Baton* baton) {
472467

473468
if (db->update_event == NULL) {
474469
// Add it.
475-
db->update_event = new AsyncUpdate(db->loop, db, UpdateCallback);
470+
db->update_event = new AsyncUpdate(db, UpdateCallback);
476471
sqlite3_update_hook(db->_handle, UpdateCallback, db);
477472
}
478473
else {
@@ -527,7 +522,7 @@ void Database::Work_BeginExec(Baton* baton) {
527522
assert(baton->db->open);
528523
assert(baton->db->_handle);
529524
assert(baton->db->pending == 0);
530-
int status = uv_queue_work(baton->db->loop,
525+
int status = uv_queue_work(uv_default_loop(),
531526
&baton->request, Work_Exec, (uv_after_work_cb)Work_AfterExec);
532527
assert(status == 0);
533528
}
@@ -627,7 +622,7 @@ void Database::Work_BeginLoadExtension(Baton* baton) {
627622
assert(baton->db->open);
628623
assert(baton->db->_handle);
629624
assert(baton->db->pending == 0);
630-
int status = uv_queue_work(baton->db->loop,
625+
int status = uv_queue_work(uv_default_loop(),
631626
&baton->request, Work_LoadExtension, reinterpret_cast<uv_after_work_cb>(Work_AfterLoadExtension));
632627
assert(status == 0);
633628
}

src/database.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ class Database : public Nan::ObjectWrap {
100100
friend class Statement;
101101

102102
protected:
103-
Database(uv_loop_t* loop_) : Nan::ObjectWrap(),
103+
Database() : Nan::ObjectWrap(),
104104
_handle(NULL),
105-
loop(loop_),
106105
open(false),
107106
closing(false),
108107
locked(false),
@@ -173,10 +172,7 @@ class Database : public Nan::ObjectWrap {
173172

174173
protected:
175174
sqlite3* _handle;
176-
public:
177-
uv_loop_t* loop;
178175

179-
protected:
180176
bool open;
181177
bool closing;
182178
bool locked;

src/macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const char* sqlite_authorizer_string(int type);
122122
assert(baton->stmt->prepared); \
123123
baton->stmt->locked = true; \
124124
baton->stmt->db->pending++; \
125-
int status = uv_queue_work(baton->stmt->db->loop, \
125+
int status = uv_queue_work(uv_default_loop(), \
126126
&baton->request, \
127127
Work_##type, reinterpret_cast<uv_after_work_cb>(Work_After##type)); \
128128
assert(status == 0);

src/statement.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ NAN_METHOD(Statement::New) {
115115
void Statement::Work_BeginPrepare(Database::Baton* baton) {
116116
assert(baton->db->open);
117117
baton->db->pending++;
118-
int status = uv_queue_work(baton->db->loop,
118+
int status = uv_queue_work(uv_default_loop(),
119119
&baton->request, Work_Prepare, (uv_after_work_cb)Work_AfterPrepare);
120120
assert(status == 0);
121121
}

src/statement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class Statement : public Nan::ObjectWrap {
174174
watcher.data = this;
175175
NODE_SQLITE3_MUTEX_INIT
176176
stmt->Ref();
177-
uv_async_init(stmt->db->loop, &watcher, async_cb);
177+
uv_async_init(uv_default_loop(), &watcher, async_cb);
178178
}
179179

180180
~Async() {

0 commit comments

Comments
 (0)