JaroslavTulach commented on a change in pull request #2523: URL: https://github.com/apache/netbeans/pull/2523#discussion_r518777355
########## File path: java/java.lsp.server/vscode/src/extension.ts ########## @@ -163,14 +163,45 @@ export function activate(context: ExtensionContext) { })); } +/** + * Pending maintenance (install) task, activations should be chained after it. + */ +let maintenance : Promise<void> | null; + +/** + * Pending activation flag. Will be cleared when the process produces some message or fails. + */ +let activationPending : boolean = false; + function activateWithJDK(specifiedJDK: string | null, context: ExtensionContext, log : vscode.OutputChannel, notifyKill: boolean): void { - if (nbProcess) { + const a : Promise<void> | null = maintenance; + if (activationPending) { + // do not activate more than once in parallel. + return; + } + activationPending = true; + if (a != null) { + a.then(() => doActivateWithJDK(specifiedJDK, context, log, notifyKill)); + } else { + doActivateWithJDK(specifiedJDK, context, log, notifyKill); + } +} + +function killNbProcess(notifyKill : boolean, specProcess?: ChildProcess) { + let p = nbProcess; + if (p && (!specProcess || specProcess == p)) { if (notifyKill) { vscode.window.setStatusBarMessage("Restarting Apache NetBeans Language Server.", 2000); } - nbProcess.kill(); + p.kill(); + // PENDING: possible race Review comment: What do you mean by possible race, @sdedic? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists