Advertisement
Cool_Dalek

PluggableEventLoop

Aug 11th, 2022
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.52 KB | None | 0 0
  1. /**
  2.  * Intended to be used internally from scheduler threads.
  3.  * Every iteration thread should poll loop and add tasks to scheduler work queues.
  4.  * And only then proceed to execute next task.
  5.  * Users should be able to register new event loops and control their affinity.
  6.  * */
  7. trait PluggableEventLoop {
  8.  
  9.   /**
  10.    * Poll events and return tasks to execute.
  11.    * Implementation should poll events from the underlying event loop and
  12.    * return all callbacks which should be executed due to fired events.
  13.    * */
  14.   def poll(): Vector[Runnable]
  15.  
  16.   /**
  17.    * Shows if the event loop is paused or resumed.
  18.    * Event loop can pause itself on its own due to implementation-specific circumstances
  19.    * (such as pausing of UI event loops due to focus lost).
  20.    * Event loop can resume itself on its own only if it was paused on its own.
  21.    * */
  22.   def isPaused: Boolean
  23.  
  24.   /**
  25.    * Request the event loop to become paused.
  26.    * Implementation must respect this request.
  27.    * Event loop can pause itself on its own due to implementation-specific circumstances
  28.    * (such as pausing of UI event loops due to focus lost).
  29.    * */
  30.   def pause(): Unit
  31.  
  32.   /**
  33.    * Request event loop to be resumed.
  34.    * Implementation may ignore this request.
  35.    * Event loop can resume itself on its own only if it was paused on its own.
  36.    * */
  37.   def resume(): Unit
  38.  
  39.   /**
  40.    * Request to shut down the event loop.
  41.    * Implementation must respect this request.
  42.    * Event loop cannot shut down on its own.
  43.    * */
  44.   def shutdown(): Unit
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement