Repository navigation
Pass thread pool impl to Map constructor - #6687
Conversation
|
@mikemorris, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jfirebaugh, @brunoabinader and @kkaefer to be potential reviewers. |
|
There's no requirement that |
|
Thanks @jfirebaugh, got that cleaned up and implemented |
|
It appears that in some (but not all) instances, @jfirebaugh do you think implementing this Node.js thread pool will require a custom |
|
So |
|
@jfirebaugh Got this ALMOST working, but tests are hanging on |
|
Try |
There was a problem hiding this comment.
This leaks the queue. NodeThreadPool::queue should be a value, not a pointer.
There was a problem hiding this comment.
Ack, needed to fix this in mapbox-gl-native/platform/node/src/node_log.cpp too.
|
I'm not quite sure what the issue I'm hitting now is, but it may be related to an implicit instantiation or something? Only thinking that because I had to move from |
|
@jfirebaugh Pushed up 755623baa863f12ed3f967fef0daae0d4b279558 which should likely be reverted, but "fixes" the issue I described in #6687 (comment) and |
|
Ugh, |
88f0eee to
76de29c
Compare
|
Not seeing ^ anymore, hitting #6705 instead. |
e700f69 to
9fa3c04
Compare
|
CI tests are all green now - what needs to happen before we can merge this @jfirebaugh? The public API of the Node.js bindings (and other platforms) didn't change, but is the ABI break with the change to the |
| HeadlessView view{ display, 1 }; | ||
| DefaultFileSource fileSource{ "benchmark/fixtures/api/cache.db", "." }; | ||
| Map map{ view, fileSource, MapMode::Still }; | ||
| ThreadPool workerThreadPool{ 4 }; |
There was a problem hiding this comment.
Rename workerThreadPool ⇢ threadPool in each of the places in this PR that are gaining a ThreadPool member. The fact that it's used for "workers" is an implementation detail.
| // setup mbgl map | ||
| mbgl::DefaultFileSource *mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource; | ||
| _mbglMap = new mbgl::Map(*_mbglView, *mbglFileSource, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default); | ||
| mbgl::ThreadPool workerThreadPool(4); |
There was a problem hiding this comment.
This does not live long enough. It's on the stack here, but it needs to outlive _mbglMap.
There was a problem hiding this comment.
Fixed this - is the stack allocation okay in bin/render.cpp, bin/glfw.cpp and the tests?
|
|
||
| mbgl::DefaultFileSource *mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource; | ||
| _mbglMap = new mbgl::Map(*_mbglView, *mbglFileSource, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default); | ||
| mbgl::ThreadPool workerThreadPool(4); |
| private: | ||
| util::AsyncQueue<std::weak_ptr<mbgl::Mailbox>>* queue; | ||
|
|
||
| class NodeThread : public Nan::AsyncWorker { |
There was a problem hiding this comment.
Rename NodeThread ⇢ Worker. It's not a thread.
|
|
||
| View& view; | ||
| FileSource& fileSource; | ||
| Scheduler& workerThreadPool; |
There was a problem hiding this comment.
Rename workerThreadPool ⇢ scheduler.
So long as all the SDKs are updated in this PR, which they are, we're good. |
jfirebaugh
left a comment
There was a problem hiding this comment.
In those cases, the Map and ThreadPool are in the same stack frame, so it's ok.
Updates mbgl::Map constructor usage everywhere Adds NodeThreadPool implementation using AsyncQueue to call Nan::AsyncQueueWorker from main thread
Fixes #3982
Put together an initial draft of subclassing
Schedulerto supply a custom thread pool implementation toMap. Currently, only theNodeMapimplementation has been updated to pass in a thread pool based onNanAsyncWorker- all other platforms will need to be updated to pass in the default thread pool implementation.I think the
NodeThread->NodeThreadPoolreference is quite unsafe currently. Should I be using astd::weak_ptror something here?I'm hitting a segfault when running
npm test, backtrace follows:/cc @jfirebaugh @miccolis