Class OnceFunc

java.lang.Object
io.javago.sync.OnceFunc
All Implemented Interfaces:
Runnable

public class OnceFunc extends Object implements Runnable
The OnceFunc class implements Go's sync.OnceFunc. A Runnable wrapper that ensures the wrapped Runnable is executed only once.
  • Constructor Details

    • OnceFunc

      public OnceFunc(Runnable func)
      Constructs a new OnceFunc that will wrap the given Runnable.
      Parameters:
      func - the Runnable to be wrapped and executed only once
  • Method Details

    • run

      public void run()
      Executes the wrapped Runnable only once. If this method is called multiple times, the wrapped Runnable will only be executed the first time.
      Specified by:
      run in interface Runnable