awslabs / aws-crt-nodejs

NodeJS bindings for the AWS Common Runtime.
Apache License 2.0
38 stars 24 forks source link

Let's try ref counting #451

Closed bretambrose closed 1 year ago

bretambrose commented 1 year ago

Revert the changes that prevented multi-init of the NAPI module and add ref-counting support and careful, matching shutdown when the last ref goes away.

https://github.com/aws/aws-iot-device-sdk-js-v2/discussions/360

A more complex solution might consider making elg/hr/bootstrap a per-environment set of data, but for now, the simplest approach with the least possibility of error is to simply have all environments reference a shared triple and use ref-counting to drop the triple once no env-users remain.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.