Class Sleeper


  • public class Sleeper
    extends Object
    A struct which can be used to select across many [`Future`]s at once without relying on a full async context.
    • Method Detail

      • from_single_future

        public static Sleeper from_single_future​(Future future)
        Constructs a new sleeper from one future, allowing blocking on it.
      • from_two_futures

        public static Sleeper from_two_futures​(Future fut_a,
                                               Future fut_b)
        Constructs a new sleeper from two futures, allowing blocking on both at once.
      • of

        public static Sleeper of​(Future[] futures)
        Constructs a new sleeper on many futures, allowing blocking on all at once.
      • wait_indefinite

        public void wait_indefinite()
        Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed.
      • wait_timeout

        public boolean wait_timeout​(long max_wait)
        Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed or the given amount of time has elapsed. Returns true if a [`Future`] completed, false if the time elapsed.