Skip to content

Commit fcac520

Browse files
committed
Switched to libuv mutexes
refs #137 (comment) - we don't actually need to depend on Boost for mutexes, even though it was gated behind `NODE_SQLITE3_BOOST_THREADING` anyway, which I can't find documented anywhere - this simplifies the threading.h file and keeps the different systems more aligned in their dependency use
1 parent f924bbb commit fcac520

File tree

2 files changed

+5
-48
lines changed

2 files changed

+5
-48
lines changed

src/async.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
#include "threading.h"
88

9-
#if defined(NODE_SQLITE3_BOOST_THREADING)
10-
#include <boost/thread/mutex.hpp>
11-
#endif
12-
13-
149
// Generic uv_async handler.
1510
template <class Item, class Parent> class Async {
1611
typedef void (*Callback)(Parent* parent, Item* item);

src/threading.h

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,10 @@
11
#ifndef NODE_SQLITE3_SRC_THREADING_H
22
#define NODE_SQLITE3_SRC_THREADING_H
33

4-
5-
#ifdef _WIN32
6-
7-
#include <windows.h>
8-
9-
#define NODE_SQLITE3_MUTEX_t HANDLE mutex;
10-
11-
#define NODE_SQLITE3_MUTEX_INIT mutex = CreateMutex(NULL, FALSE, NULL);
12-
13-
#define NODE_SQLITE3_MUTEX_LOCK(m) WaitForSingleObject(*m, INFINITE);
14-
15-
#define NODE_SQLITE3_MUTEX_UNLOCK(m) ReleaseMutex(*m);
16-
17-
#define NODE_SQLITE3_MUTEX_DESTROY CloseHandle(mutex);
18-
19-
#elif defined(NODE_SQLITE3_BOOST_THREADING)
20-
21-
#include <boost/thread/mutex.hpp>
22-
23-
#define NODE_SQLITE3_MUTEX_t boost::mutex mutex;
24-
25-
#define NODE_SQLITE3_MUTEX_INIT
26-
27-
#define NODE_SQLITE3_MUTEX_LOCK(m) (*m).lock();
28-
29-
#define NODE_SQLITE3_MUTEX_UNLOCK(m) (*m).unlock();
30-
31-
#define NODE_SQLITE3_MUTEX_DESTROY mutex.unlock();
32-
33-
#else
34-
35-
#define NODE_SQLITE3_MUTEX_t pthread_mutex_t mutex;
36-
37-
#define NODE_SQLITE3_MUTEX_INIT pthread_mutex_init(&mutex,NULL);
38-
39-
#define NODE_SQLITE3_MUTEX_LOCK(m) pthread_mutex_lock(m);
40-
41-
#define NODE_SQLITE3_MUTEX_UNLOCK(m) pthread_mutex_unlock(m);
42-
43-
#define NODE_SQLITE3_MUTEX_DESTROY pthread_mutex_destroy(&mutex);
44-
45-
#endif
46-
4+
#define NODE_SQLITE3_MUTEX_t uv_mutex_t mutex;
5+
#define NODE_SQLITE3_MUTEX_INIT uv_mutex_init(&mutex);
6+
#define NODE_SQLITE3_MUTEX_LOCK(m) uv_mutex_lock(m);
7+
#define NODE_SQLITE3_MUTEX_UNLOCK(m) uv_mutex_unlock(m);
8+
#define NODE_SQLITE3_MUTEX_DESTROY uv_mutex_destroy(&mutex);
479

4810
#endif // NODE_SQLITE3_SRC_THREADING_H

0 commit comments

Comments
 (0)