提交 3d93cc4f 编写于 作者: J João Moreno

Merge pull request #827 from joaomoreno/mutex

Support Windows mutexes

fixes #822 
......@@ -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"
}
}
/*---------------------------------------------------------------------------------------------
* 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;
}
}
\ No newline at end of file
......@@ -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);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册