Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

worker usage should be customizable #3982

Closed

Description

@jfirebaugh

For node, we don't want to spawn four threads for each Map instance. Instead, the node thread pool should be used.

Worker needs to be more like FileSource -- an abstract interface that can be replaced with different implementations depending on the platform.

Activity

  1. added
    Node.js
    on Feb 17, 2016
  2. tmpsantos commented on Feb 17, 2016

    @tmpsantos
    Contributor

    Wouldn't make mbgl::Worker thread-safe (it is almost already) and share it across all the map objects a more maintainable option?

  3. jfirebaugh commented on Feb 17, 2016

    @jfirebaugh
    ContributorAuthor

    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.

  4. jfirebaugh commented on Oct 10, 2016

    @jfirebaugh
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Node.jsrefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions