fix iOS debugger
This commit is contained in:
parent
e2c6a5f906
commit
521fd12937
42
src/rpc.cpp
42
src/rpc.cpp
|
@ -28,7 +28,6 @@
|
||||||
#include "object_accessor.hpp"
|
#include "object_accessor.hpp"
|
||||||
#include "shared_realm.hpp"
|
#include "shared_realm.hpp"
|
||||||
#include "results.hpp"
|
#include "results.hpp"
|
||||||
#include <android/looper.h>
|
|
||||||
|
|
||||||
using namespace realm;
|
using namespace realm;
|
||||||
using namespace realm::rpc;
|
using namespace realm::rpc;
|
||||||
|
@ -83,15 +82,30 @@ RPCServer*& get_rpc_server(JSGlobalContextRef ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RPCWorker::RPCWorker() {
|
#ifdef REALM_PLATFORM_APPLE
|
||||||
//m_thread = std::thread([this]() {
|
void runLoopFunc(CFRunLoopRef loop, RPCWorker* rpcWorker) {
|
||||||
//m_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
auto m_stop = false;
|
||||||
|
CFRunLoopPerformBlock(loop, kCFRunLoopDefaultMode,
|
||||||
|
^{
|
||||||
|
rpcWorker->try_run_task();
|
||||||
|
if (rpcWorker->should_stop()) {
|
||||||
|
CFRunLoopStop(CFRunLoopGetCurrent());
|
||||||
|
} else {
|
||||||
|
runLoopFunc(loop, rpcWorker);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CFRunLoopWakeUp(loop);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: Create ALooper/CFRunLoop to support async calls.
|
RPCWorker::RPCWorker() {
|
||||||
//while (!m_stop) {
|
#ifdef REALM_PLATFORM_APPLE
|
||||||
//try_run_task();
|
m_thread = std::thread([this]() {
|
||||||
//}
|
m_loop = CFRunLoopGetCurrent();
|
||||||
//});
|
runLoopFunc(m_loop, this);
|
||||||
|
CFRunLoopRun();
|
||||||
|
});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RPCWorker::~RPCWorker() {
|
RPCWorker::~RPCWorker() {
|
||||||
|
@ -139,11 +153,17 @@ bool RPCWorker::try_run_task() {
|
||||||
return m_stop;
|
return m_stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RPCWorker::should_stop() {
|
||||||
|
return m_stop;
|
||||||
|
}
|
||||||
|
|
||||||
void RPCWorker::stop() {
|
void RPCWorker::stop() {
|
||||||
if (!m_stop) {
|
if (!m_stop) {
|
||||||
m_stop = true;
|
m_stop = true;
|
||||||
//m_thread.join();
|
#if REALM_PLATFORM_APPLE
|
||||||
//m_looper = nullptr;
|
m_thread.join();
|
||||||
|
m_loop = nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
#include "jsc_types.hpp"
|
#include "jsc_types.hpp"
|
||||||
#include "jsc_protected.hpp"
|
#include "jsc_protected.hpp"
|
||||||
#include <android/looper.h>
|
|
||||||
|
|
||||||
namespace realm {
|
namespace realm {
|
||||||
|
|
||||||
|
@ -49,11 +48,14 @@ class RPCWorker {
|
||||||
bool try_run_task();
|
bool try_run_task();
|
||||||
void stop();
|
void stop();
|
||||||
json try_pop_task_result();
|
json try_pop_task_result();
|
||||||
|
bool should_stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_stop = false;
|
bool m_stop = false;
|
||||||
//ALooper* m_looper;
|
#if REALM_PLATFORM_APPLE
|
||||||
//std::thread m_thread;
|
std::thread m_thread;
|
||||||
|
CFRunLoopRef m_loop;
|
||||||
|
#endif
|
||||||
ConcurrentDeque<std::packaged_task<json()>> m_tasks;
|
ConcurrentDeque<std::packaged_task<json()>> m_tasks;
|
||||||
ConcurrentDeque<std::future<json>> m_futures;
|
ConcurrentDeque<std::future<json>> m_futures;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue