npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cds_job.c

v1.2016.4

Published

C++11 lock-free job queue; Cort Stratton (2016).

Readme

cds_job

This single header file C++11 library provides a lock-free, work-stealing job queue system, by Cort Stratton. It is based on an implementation described extensively by Stefan Reinalter on his blog.

This library is a work in progress, and should not yet be used in production code.

No documentation yet, but here's a list of things to keep in mind:

  • Each job's data is stored (as a copy) in the leftover space of the Job structure itself.
    • If you pass more data to a job than will fit in this space, you fail.
    • This should be handled with a different createJob() variant.
  • Each job can have a "parent" job specified at creation time, but this has nothing to do with job dependencies. It's merely a way to say "when you wait on a job that's a parent, you wait on all its children (recursively) as well."
  • Waiting on a job with waitForJob() is a read-only operation, completely orthogonal to job execution.
    • waitForJob() does not attempt to steal or execute the specified job; instead, it causes the thread to process jobs from its own queue (and/or by stealing from other queues) until the specified job is finished.
    • The job you're waiting on may very well be executed while you're waiting for it to complete. This is fine. The wait will not terminate until both the parent and all its children have been executed. Note that parent/child execution order is NOT guaranteed.
    • Waiting on a dummy root job seems common enough that there should be a shortcut.
  • For efficiency, Jobs are allocated out of pools stored in TLS. Each worker thread has a maximum number of jobs it can have "in-flight" simultaneously.
    • There is currently no check to enforce the maxJobsPerThread limit; accidentally exceeding this limit is by far the most common source of nasty bugs I've encountered so far.
    • This scheme is best suited to cases where the worker threads are generating their own work (in roughly similar quantities), rather than one master thread generating an entire workload and letting the workers divvy it up. Although, see parallel_for() for an example of the latter strategy in action.
  • Currently, threads that can't find work to do will call YieldProcessor(). This is effectively a busy-wait, and is totally inappropriate in production code. The original author suggests various approaches to put workers to sleep when there's no work left, and wake them again when more is ready.

Installation

Run:

$ npm i cds_job.c

And then include cds_job.h as follows:

#include "node_modules/cds_job.c/cds_job.h"

Key Features / Design Goals

  • Identical API on all supported platforms. The following platforms are tested regularly:
    • Microsoft Windows 7
      • Visual Studio 2010
      • Visual Studio 2012
      • Visual Studio 2013
    • Linux Mint
      • LLVM/Clang 3.5
      • gcc 4.8.4
    • Apple OSX
      • Apple LLVM/Clang 6.1.0
  • No (mandatory) external dependencies. Only C++11 standard library functions are used.
  • Dirt-simple integration. Just a single header file to include in your project.
  • Public domain license terms.

Acknowledgements

ORG