Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

node-singleton implementation to release the usb listening #434

Closed
gre opened this issue Jan 2, 2020 · 1 comment
Closed

node-singleton implementation to release the usb listening #434

gre opened this issue Jan 2, 2020 · 1 comment
Assignees

Comments

@gre
Copy link
Contributor

gre commented Jan 2, 2020

need to reboot this idea

// stopMonitoring is causing trouble so not using that implem for now
let totalMonitor = 0;
const monitor = () => {
if (totalMonitor === 0) {
log("usb-detection", "startMonitoring");
usbDetect.startMonitoring();
}
totalMonitor++;
return () => {
totalMonitor--;
if (totalMonitor === 0) {
log("usb-detection", "stopMonitoring");
usbDetect.stopMonitoring();
}
};
};

because without doing stopMonitoring(), you will have a node thread never ending.

@gre
Copy link
Contributor Author

gre commented Jan 4, 2020

putting back that code creates bad seg fault because of MadLittleMods/node-usb-detection#57

another idea will be to process.on("exit", () => usbDetect.stopMonitoring())

@gre gre closed this as completed in fc91400 Jan 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant