Class Blocker

java.lang.Object
org.eclipse.jetty.util.Blocker

public class Blocker extends Object
Utility class that provides blocking Runnable and Callback instances. These can either be shared (and mutually excluded from concurrent usage) or single usage. The instances are autocloseable and will emit a warning if the instance is not completed within close.

Non shared Runnable

     try(Blocker.Runnable onAction = Blocker.runnable())
     {
         someMethod(onAction);
         onAction.block();
     }
 

Shared Runnable

     Blocker.SharedRunnable shared = new Blocker.Shared();
     // ...
     try(Blocker.Runnable onAction = shared.runnable())
     {
         someMethod(onAction);
         onAction.block();
     }
 

Non shared Callback

     try(Blocker.Callback callback = Blocker.callback())
     {
         someMethod(callback);
         callback.block();
     }
 

Shared Callback

     Blocker.Shared blocker = new Blocker.Shared();
     // ...
     try(Blocker.Callback callback = blocker.callback())
     {
         someMethod(callback);
         callback.block();
     }