Class Theater

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> Call<T> call​(Cont<T> cont)
      Returns a Call that completes the continuation.
      protected <T> void callDidBind​(Cont<?> cont, T value)
      Introspection callback invoked immediately after a call to cont.bind(value) returns nominally.
      protected void callDidFail​(Cont<?> cont, Throwable error)
      Introspection callback invoked immediately after a call to cont.bind(T) fails by throwing an error.
      protected void callDidTrap​(Cont<?> cont, Throwable error)
      Introspection callback invoked immediately after a call to cont.trap(error) returns nominally.
      protected <T> void callWillBind​(Cont<T> cont, T value)
      Introspection callback invoked immediately before a call to cont.bind(value).
      protected void callWillCue​(Cont<?> cont)
      Introspection callback invoked before a cont call is cued for execution.
      protected void callWillTrap​(Cont<?> cont, Throwable error)
      Introspection callback invoked immediately before a call to cont.trap(error).
      protected void didFail​(Throwable error)
      Lifecycle callback invoked if this Theater encounters an internal error.
      protected void didStart()
      Lifecycle callback invoked before the thread pool starts up.
      protected void didStop()
      Lifecycle callback invoked after the thread pool shuts down.
      void execute​(Runnable runnable)
      Schedules a runnable for concurrent execution.
      TimerRef setTimer​(long millis, TimerFunction timer)
      Schedules timer to execute after millis milliseconds have elapsed.
      void start()
      Ensures that this Theater is up and running.
      void stop()
      Ensures that this Theater has been permanently stopped, shutting down the thread pool, if it's currently running.
      TaskRef task​(TaskFunction task)
      Returns an uncued TaskRef bound to the task, which can later be used to cue the task.
      protected void taskDidCancel​(TaskFunction task)
      Introspection callback invoked after a cued task is canceled.
      protected void taskDidFail​(TaskFunction task, Throwable error)
      Introspection callback invoked immediately after task.runTask() fails by throwing an error.
      protected void taskDidRun​(TaskFunction task)
      Introspection callback invoked immediately after task.runTask() returns nominally.
      protected void taskWillCue​(TaskFunction task)
      Introspection callback invoked before a task is cued for execution.
      protected void taskWillRun​(TaskFunction task)
      Introspection callback invoked immediately before task.runTask() is executed.
      TimerRef timer​(TimerFunction timer)
      Returns an unscheduled TimerRef bound to timer, which can later be used to schedule timer.
      void uncaughtException​(Thread thead, Throwable error)  
    • Constructor Detail

      • Theater

        public Theater​(String name,
                       int parallelism,
                       Schedule schedule)
      • Theater

        public Theater​(String name,
                       int parallelism)
      • Theater

        public Theater​(String name)
      • Theater

        public Theater​(int parallelism,
                       Schedule schedule)
      • Theater

        public Theater​(int parallelism)
      • Theater

        public Theater​(Schedule schedule)
      • Theater

        public Theater()
    • Method Detail

      • start

        public void start()
        Ensures that this Theater is up and running.
        Throws:
        IllegalStateException - if this Theater has been stopped.
      • stop

        public void stop()
        Ensures that this Theater has been permanently stopped, shutting down the thread pool, if it's currently running. Upon return, this Theater is guaranteed to be in the stopped state.
      • execute

        public void execute​(Runnable runnable)
        Description copied from interface: Stage
        Schedules a runnable for concurrent execution.
        Specified by:
        execute in interface Executor
        Specified by:
        execute in interface Stage
      • task

        public TaskRef task​(TaskFunction task)
        Description copied from interface: Stage
        Returns an uncued TaskRef bound to the task, which can later be used to cue the task.
        Specified by:
        task in interface Stage
      • call

        public <T> Call<T> call​(Cont<T> cont)
        Description copied from interface: Stage
        Returns a Call that completes the continuation.
        Specified by:
        call in interface Stage
      • timer

        public TimerRef timer​(TimerFunction timer)
        Description copied from interface: Schedule
        Returns an unscheduled TimerRef bound to timer, which can later be used to schedule timer.
        Specified by:
        timer in interface Schedule
      • setTimer

        public TimerRef setTimer​(long millis,
                                 TimerFunction timer)
        Description copied from interface: Schedule
        Schedules timer to execute after millis milliseconds have elapsed. Returns a TimerRef that can be used to check the status of, reschedule, and cancel timer.
        Specified by:
        setTimer in interface Schedule
      • didStart

        protected void didStart()
        Lifecycle callback invoked before the thread pool starts up.
      • didStop

        protected void didStop()
        Lifecycle callback invoked after the thread pool shuts down.
      • didFail

        protected void didFail​(Throwable error)
        Lifecycle callback invoked if this Theater encounters an internal error.
      • taskWillCue

        protected void taskWillCue​(TaskFunction task)
        Introspection callback invoked before a task is cued for execution.
      • taskDidCancel

        protected void taskDidCancel​(TaskFunction task)
        Introspection callback invoked after a cued task is canceled.
      • taskWillRun

        protected void taskWillRun​(TaskFunction task)
        Introspection callback invoked immediately before task.runTask() is executed.
      • taskDidRun

        protected void taskDidRun​(TaskFunction task)
        Introspection callback invoked immediately after task.runTask() returns nominally.
      • taskDidFail

        protected void taskDidFail​(TaskFunction task,
                                   Throwable error)
        Introspection callback invoked immediately after task.runTask() fails by throwing an error.
      • callWillCue

        protected void callWillCue​(Cont<?> cont)
        Introspection callback invoked before a cont call is cued for execution.
      • callWillBind

        protected <T> void callWillBind​(Cont<T> cont,
                                        T value)
        Introspection callback invoked immediately before a call to cont.bind(value).
      • callDidBind

        protected <T> void callDidBind​(Cont<?> cont,
                                       T value)
        Introspection callback invoked immediately after a call to cont.bind(value) returns nominally.
      • callWillTrap

        protected void callWillTrap​(Cont<?> cont,
                                    Throwable error)
        Introspection callback invoked immediately before a call to cont.trap(error).
      • callDidTrap

        protected void callDidTrap​(Cont<?> cont,
                                   Throwable error)
        Introspection callback invoked immediately after a call to cont.trap(error) returns nominally.
      • callDidFail

        protected void callDidFail​(Cont<?> cont,
                                   Throwable error)
        Introspection callback invoked immediately after a call to cont.bind(T) fails by throwing an error.