This is an automated email from the ASF dual-hosted git repository. jtulach pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans-html4j.git
commit 5b0a977698930c7fc400355bc29f27a1a1146e39 Author: Jaroslav Tulach <jaroslav.tul...@apidesign.org> AuthorDate: Wed Dec 23 14:24:24 2020 +0100 No need to obtain for locking in exec --- .../org/netbeans/html/presenters/spi/Generic.java | 82 +++++++++++----------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/generic/src/main/java/org/netbeans/html/presenters/spi/Generic.java b/generic/src/main/java/org/netbeans/html/presenters/spi/Generic.java index 83e5398..fd06b6d 100644 --- a/generic/src/main/java/org/netbeans/html/presenters/spi/Generic.java +++ b/generic/src/main/java/org/netbeans/html/presenters/spi/Generic.java @@ -748,56 +748,54 @@ abstract class Generic implements Fn.Presenter, Fn.KeepAlive, Flushable { } final Object exec(int id, String fn) { - Object ret; + assert Thread.holdsLock(lock()); boolean first; - synchronized (lock()) { - if (deferred != null) { - deferred.append(fn); - fn = deferred.toString(); - deferred = null; - log(Level.FINE, "Flushing {0}", fn); - } + if (deferred != null) { + deferred.append(fn); + fn = deferred.toString(); + deferred = null; + log(Level.FINE, "Flushing {0}", fn); + } - { - Item c = topMostCall(); - if (c != null && c.method != null) { - c.inJava(); - lock().notifyAll(); - } + { + Item c = topMostCall(); + if (c != null && c.method != null) { + c.inJava(); + lock().notifyAll(); } + } - Item myCall; - boolean load; - final Item top = topMostCall(); - if (top != null) { - myCall = registerCall(new Item(id, top, fn)); - load = synchronous; - first = false; - } else { - myCall = registerCall(new Item(id, null, null)); - load = true; - first = true; + Item myCall; + boolean load; + final Item top = topMostCall(); + if (top != null) { + myCall = registerCall(new Item(id, top, fn)); + load = synchronous; + first = false; + } else { + myCall = registerCall(new Item(id, null, null)); + load = true; + first = true; + } + if (load) { + loadJS(fn); + } + for (;;) { + if (myCall.typeof != null) { + break; } - if (load) { - loadJS(fn); + try { + lock().wait(); + } catch (InterruptedException ex) { + log(Level.SEVERE, null, ex); } - for (;;) { - if (myCall.typeof != null) { - break; - } - try { - lock().wait(); - } catch (InterruptedException ex) { - log(Level.SEVERE, null, ex); - } - Item c = topMostCall(); - if (c != null) { - c.inJava(); - } - lock().notifyAll(); + Item c = topMostCall(); + if (c != null) { + c.inJava(); } - ret = valueOf(myCall.typeof, (String) myCall.result); + lock().notifyAll(); } + Object ret = valueOf(myCall.typeof, (String) myCall.result); if (first) { arguments.clear(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists