Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d3m3vilurr/aumutex
Named mutex terminated due to the process end of automatic
https://github.com/d3m3vilurr/aumutex
Last synced: 20 days ago
JSON representation
Named mutex terminated due to the process end of automatic
- Host: GitHub
- URL: https://github.com/d3m3vilurr/aumutex
- Owner: d3m3vilurr
- License: bsd-2-clause
- Created: 2015-10-22T06:14:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-22T08:24:59.000Z (about 9 years ago)
- Last Synced: 2024-12-10T14:49:36.609Z (about 1 month ago)
- Language: C++
- Size: 85.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
aumutex
=======Named mutex terminated due to the process end of automatic
## Examples
```javascript
// from test.js
var cluster = require('cluster');
var sleep = require('sleep');
var aumutex = require('./aumutex');var mutex_name = '/var/tmp/mymutex';
if (cluster.isMaster) {
cluster.fork();
cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
sleep.sleep(2);var master_mutex = aumutex.create(mutex_name);
console.info('[MASTER] create');
console.info('[MASTER] wait');
aumutex.enter(master_mutex);
console.info('[MASTER] enter');
console.info('[MASTER] close');
aumutex.close(master_mutex);
master_mutex = aumutex.create(mutex_name);
console.info('[MASTER] re-create');
console.info('[MASTER] wait');
sleep.sleep(2);
aumutex.enter(master_mutex);
console.info('[MASTER] re-enter');
aumutex.close(master_mutex);
console.info('[MASTER] process.exit()');
process.exit();} else {
var worker_mutex = aumutex.create(mutex_name);
console.info('[WORKER] create');
aumutex.enter(worker_mutex);
console.info('[WORKER] enter');
sleep.sleep(2);
console.info('[WORKER] leave');
aumutex.leave(worker_mutex);
sleep.sleep(2);
console.info('[WORKER] wait');
aumutex.enter(worker_mutex);
console.info('[WORKER] re-enter');
sleep.sleep(2);
console.info('[WORKER] process.exit()');
process.exit();
}--- result ----
[WORKER] create
[WORKER] enter
[MASTER] create
[MASTER] wait
[WORKER] leave
[MASTER] enter
[MASTER] close
[MASTER] re-create
[MASTER] wait
[WORKER] wait
[WORKER] re-enter
[WORKER] process.exit()
[MASTER] re-enter
[MASTER] process.exit()
```