mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 11:10:48 +00:00
Merge pull request #827 from joaomoreno/mutex
Support Windows mutexes fixes #822
This commit is contained in:
commit
3d93cc4fd5
4 changed files with 42 additions and 2 deletions
16
npm-shrinkwrap.json
generated
16
npm-shrinkwrap.json
generated
|
@ -460,6 +460,22 @@
|
|||
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"windows-mutex": {
|
||||
"version": "0.1.3",
|
||||
"from": "windows-mutex@0.1.3",
|
||||
"dependencies": {
|
||||
"bindings": {
|
||||
"version": "1.2.1",
|
||||
"from": "bindings@>=1.2.1 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz"
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.1.0",
|
||||
"from": "nan@>=2.1.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.1.0.tgz"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/mocha/bin/_mocha",
|
||||
"preinstall": "node build/npm/preinstall.js",
|
||||
"preinstall": "node build/npm/preinstall.js",
|
||||
"postinstall": "npm --prefix extensions/csharp-o/ install extensions/csharp-o/ && npm --prefix extensions/vscode-api-tests/ install extensions/vscode-api-tests/"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -89,5 +89,8 @@
|
|||
"ghooks": {
|
||||
"pre-commit": "node build/gulpfile.hygiene.js"
|
||||
}
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"windows-mutex": "^0.1.3"
|
||||
}
|
||||
}
|
||||
|
|
12
src/typings/windows-mutex.ts
Normal file
12
src/typings/windows-mutex.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
declare module 'windows-mutex' {
|
||||
export class Mutex {
|
||||
constructor(name: string);
|
||||
isActive(): boolean;
|
||||
release(): void;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ import app = require('app');
|
|||
import fs = require('fs');
|
||||
import dialog = require('dialog');
|
||||
import shell = require('shell');
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import {assign} from 'vs/base/common/objects';
|
||||
import platform = require('vs/base/common/platform');
|
||||
|
@ -233,6 +232,15 @@ function setupIPC(): TPromise<Server> {
|
|||
return setup(true);
|
||||
}
|
||||
|
||||
function setupMutex() {
|
||||
try {
|
||||
var Mutex = (<any> require.__$__nodeRequire('windows-mutex')).Mutex;
|
||||
new Mutex('vscode');
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
// On some platforms we need to manually read from the global environment variables
|
||||
// and assign them to the process environment (e.g. when doubleclick app on Mac)
|
||||
getUserEnvironment()
|
||||
|
@ -241,6 +249,7 @@ getUserEnvironment()
|
|||
|
||||
return timebomb()
|
||||
.then(setupIPC)
|
||||
.then(ipcServer => { setupMutex(); return ipcServer; })
|
||||
.then(ipcServer => main(ipcServer, userEnv));
|
||||
})
|
||||
.done(null, quit);
|
||||
|
|
Loading…
Reference in a new issue