Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Questions/Brainstorming #50

Closed
3 of 4 tasks
GretaCB opened this issue Jun 30, 2017 · 4 comments
Closed
3 of 4 tasks

[WIP] Questions/Brainstorming #50

GretaCB opened this issue Jun 30, 2017 · 4 comments

Comments

@GretaCB
Copy link
Contributor

GretaCB commented Jun 30, 2017

Per discussion with @springmeyer , outlining possible next steps for node-cpp-skel and capturing best practices to document and integrate into the skel design.

Questions to answer

  • What does it look like to have the variable that represents an instance of a class accessible in the threadpool?

  • What is the role of a singleton and how is it related to other design patterns for sync/async?

  • When passing data to thread pool, the data needs to be a type that is safe to pass into the thread pool. What makes a type safe to pass into the thread pool?

    • Two scenarios that are safe:
      • Copy data to a C++ object (pure, part of the C++ std lib...not V8)
      • Copy V8 data: Extra work to keep the V8 object alive, avoids the object perhaps getting deleted (trick: use v8::Persistant)

Designing skel:

Goal 1)

  • Provide examples of objects that feel real-world, actionable, and sturdy
  • Unlocks: ability to fork and run fast and feel confidence the foundation is a best practice

Goal 2)

  • Provide incremental examples that build complexity gradually
  • Unlocks: easier for beginning developers to understand gradually why extra complexity is needed

Preliminary conclusion: object-sync is caught between these worlds

Terms to learn

Standard C++

  • Singleton - is a general programming concept for creating a instance once in the process
    • mapnik uses singletons for datasource plugin and font registration
  • static keyword
  • reference (what does the & mean?)

V8

  • Nan::Persistent (which is really v8::Persistent)
  • v8::FunctionTemplate and v8::Function
  • Nan::ObjectWrap

Possible next steps:

  • @springmeyer could add/edit comments and provide them in another PR
  • Build ^^ items into the cpp glossary (@GretaCB first pass)
  • Object async example: Demonstrate how we safely and efficiently utilize the threadpool to do work on data.
    Two options:
    • vt-shaver example:
      • Filters class, exposed in JS
      • Able to create the Filters class once (as object in JS)
      • Standalone shave function access Filters as an argument
      • Filters is passed into the threadpool
    • node-mapnik design: Classes expose method
@GretaCB
Copy link
Contributor Author

GretaCB commented Jul 11, 2017

Update

Per chat with @springmeyer when running through #51, I plan to:

  • split the README into different docs:
    • /docs/*.md: Info about C++ best practices, add-on conventions, explanation of files, and general 101
    • README.md: The main README will be a great template README that developers can use for their own add-ons when using the skel as a baseline (how to install, run tests, build, publish, etc)
  • Finalize object_async example
  • Expand in the docs why each example is relevant/useful and when you would use each
  • Comment sweep: Run through each example and config files to make sure relevant info is included and consistent within the comments, and that API.md is up to date
  • Run .clang-format
  • Performance section? Per chat with @springmeyer , we discussed that we should iterate on the bench/performance docs after having a realworld module in progress using the skel. See next check box below. But really want to make this a highlight since this is one of the main inspirations behind this skel, how to write high performance code.
  • Put it into action by creating a new module from scratch (chat with @springmeyer about what module that could be). And use this as a way to feed missing docs/comments/examples back into the skel.
  • Get feedback from mapbox team

@GretaCB GretaCB mentioned this issue Jul 11, 2017
3 tasks
@springmeyer
Copy link
Contributor

Build ^^ items into the cpp glossary (@GretaCB first pass)

mapbox/cpp@92af068 and mapbox/cpp@beb75bf

@springmeyer
Copy link
Contributor

springmeyer commented Aug 2, 2017

@GretaCB thanks for catching up on skel today voice. To help get to the finish line for this phase I've reviewed all open issues and commented on ones that I think are actionable. Of those that are actionable I think these are the priority things to finish before you move along:

@springmeyer
Copy link
Contributor

woot @GretaCB - everything above is checked. Shall we close?

@GretaCB GretaCB closed this as completed Nov 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants