noblepaul commented on a change in pull request #1669:
URL: https://github.com/apache/lucene-solr/pull/1669#discussion_r454701342



##########
File path: solr/core/src/java/org/apache/solr/pkg/PackageListeners.java
##########
@@ -96,15 +97,42 @@ private synchronized void 
invokeListeners(PackageLoader.Package pkg) {
 
 
   public interface Listener {
-    /**Name of the package or null to loisten to all package changes
+    /**Name of the package or null to listen to all package changes
      */
     String packageName();
 
     PluginInfo pluginInfo();
 
-    void changed(PackageLoader.Package pkg);
+    void changed(PackageLoader.Package pkg, Ctx ctx);
 
     PackageLoader.Package.Version getPackageVersion();
+    class Ctx {
+      private Map<String, Runnable > runLater;
+
+      /** If there are multiple packages to be updated and there are multiple 
listeners,
+       * This is executed after all of the {@link 
Listener#changed(PackageLoader.Package, Ctx)}
+       * calls are invoked. The name is a unique identifier that can be used 
by consumers to avoid duplicate
+       * If no deduplication is required, use null
+       * runnable objects
+       */
+      public void runLater(String name,  Runnable runnable  ) {
+        if(runLater == null) runLater = new LinkedHashMap<>();
+        if(name == null) {
+          name = runnable.getClass().getSimpleName() + "@" + 
runnable.hashCode();
+        }
+        runLater.put(name, runnable);
+      }
+      private void runLaterTasks(){
+        if(runLater == null) return;
+        new Thread(() -> runLater.forEach((s, runnable) -> {

Review comment:
       True. This needs to be done more gracefully.




----------------------------------------------------------------
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: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to