You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
It wouldn't be ideal for node. Node already has a built-in concept of a thread worker pool, which native extensions are expected to use for CPU-intensive tasks. The right thing for an extension to do is use that pool, not launch its own threads.
We now have an abstract interface that can facilitate this: Scheduler. We could, for example, write a subclass that implements Scheduler::schedule via Nan::AsyncQueueWorker. The worker Execute implementation would do:
if (auto locked = mailbox.lock()) {
locked->receive();
}
(Actually this logic is already repeated here and here and we should extract it as static void Mailbox::maybeReceive(std::weak_ptr<Mailbox>).)
The other thing we need to do is externalize the dependency, passing a Scheduler& into the Map constructor as we do View& and FileSource&, rather than creating it internally. This will need to be a coordinated change across all SDKs.
Activity
tmpsantos commentedon Feb 17, 2016
Wouldn't make
mbgl::Workerthread-safe (it is almost already) and share it across all the map objects a more maintainable option?jfirebaugh commentedon Feb 17, 2016
It wouldn't be ideal for node. Node already has a built-in concept of a thread worker pool, which native extensions are expected to use for CPU-intensive tasks. The right thing for an extension to do is use that pool, not launch its own threads.
jfirebaugh commentedon Oct 10, 2016
We now have an abstract interface that can facilitate this:
Scheduler. We could, for example, write a subclass that implementsScheduler::scheduleviaNan::AsyncQueueWorker. The workerExecuteimplementation would do:(Actually this logic is already repeated here and here and we should extract it as
static void Mailbox::maybeReceive(std::weak_ptr<Mailbox>).)The other thing we need to do is externalize the dependency, passing a
Scheduler&into theMapconstructor as we doView&andFileSource&, rather than creating it internally. This will need to be a coordinated change across all SDKs.