Class Kompics

java.lang.Object
se.sics.kompics.Kompics

public final class Kompics
extends Object
The Kompics class.
Version:
$Id$
Author:
Cosmin Arad <[email protected]>, Jim Dowling <[email protected]>, Lars Kroll <[email protected]>
  • Field Details

  • Method Details

    • setScheduler

      public static void setScheduler​(Scheduler sched)
      Set the Kompics runtime scheduler.
      Parameters:
      sched - the scheduler to set
      Throws:
      RuntimeException - if the Kompics runtime is already running
    • getScheduler

      public static Scheduler getScheduler()
      Get the current Kompics runtime scheduler.
      Returns:
      the current scheduler
    • setFaultHandler

      public static void setFaultHandler​(FaultHandler fh)
      Set the root fault handler to its default.
      Parameters:
      fh - the new root fault handler
      Throws:
      RuntimeException - if the Kompics runtime is already running
    • resetFaultHandler

      public static void resetFaultHandler()
      Reset the root fault handler to its default.
      Throws:
      RuntimeException - if the Kompics runtime is already running
    • getFaultHandler

      public static FaultHandler getFaultHandler()
      Get the root fault handler.
      Returns:
      the root fault handler
    • setConfig

      public static void setConfig​(Config conf)
      Set the root config to the default value.
      Parameters:
      conf - the new config to set
      Throws:
      RuntimeException - if the Kompics runtime is already running
    • resetConfig

      public static void resetConfig()
      Reset the root config to the default value.
      Throws:
      RuntimeException - if the Kompics runtime is already running
    • getConfig

      public static Config getConfig()
      Get the top-level config instance. Will load a default config, if none was set before.
      Returns:
      the root config
    • isOn

      public static boolean isOn()
      Checks if the Kompics runtime is currently running.
      Returns:
      true, if its running
    • createAndStart

      public static <C extends ComponentDefinition> void createAndStart​(Class<C> main)
      Creates the top-level component and starts it together with the Kompics runtime. The value Init.NONE is passed to the root component.
      Type Parameters:
      C - the type of the root component
      Parameters:
      main - the class instance of the root component
    • createAndStart

      public static <C extends ComponentDefinition> void createAndStart​(Class<C> main, Init<C> initEvent)
      Creates the top-level component and starts it together with the Kompics runtime. Passes the provided init event to the root component.
      Type Parameters:
      C - the type of the root component
      Parameters:
      main - the class instance of the root component
      initEvent - the init event to pass to the root component
    • createAndStart

      public static <C extends ComponentDefinition> void createAndStart​(Class<C> main, int workers)
      Creates the top-level component and starts it together with the Kompics runtime. The value Init.NONE is passed to the root component.
      Type Parameters:
      C - the type of the root component
      Parameters:
      main - the class instance of the root component
      workers - the number of workers to use in the runtime's threadpool
    • createAndStart

      public static <C extends ComponentDefinition> void createAndStart​(Class<C> main, Init<C> initEvent, int workers)
      Creates the top-level component and starts it together with the Kompics runtime. The value Init.NONE is passed to the root component.
      Type Parameters:
      C - the type of the root component
      Parameters:
      main - the class instance of the root component
      initEvent - the init event to pass to the root component
      workers - the number of workers to use in the runtime's threadpool
    • createAndStart

      public static <C extends ComponentDefinition> void createAndStart​(Class<C> main, int workers, int maxEventExecuteNumber)
      Creates the top-level component and starts it together with the Kompics runtime. The value Init.NONE is passed to the root component.
      Type Parameters:
      C - the type of the root component
      Parameters:
      main - the class instance of the root component
      workers - the number of workers to use in the runtime's threadpool
      maxEventExecuteNumber - the maximum number of events to execute before forcing a rescheduling of a component
    • createAndStart

      public static <C extends ComponentDefinition> void createAndStart​(Class<C> main, Init<C> initEvent, int workers, int maxEventExecuteNumber)
      Creates the top-level component and starts it together with the Kompics runtime. The value Init.NONE is passed to the root component.
      Type Parameters:
      C - the type of the root component
      Parameters:
      main - the class instance of the root component
      initEvent - the init event to pass to the root component
      workers - the number of workers to use in the runtime's threadpool
      maxEventExecuteNumber - the maximum number of events to execute before forcing a rescheduling of a component
    • asyncShutdown

      public static void asyncShutdown()
      Asynchronously shut down the Kompics runtime.

      Can be used safely from within components.

    • shutdown

      public static void shutdown()
      Synchronously shut down the Kompics runtime.

      Can not be used safely from within Kompics components. Use asyncShutdown() instead.

    • forceShutdown

      public static void forceShutdown()
      Force an immediate shutdown of the Kompics runtime.

      Can not be used safely from within Kompics components.

    • waitForTermination

      public static void waitForTermination() throws InterruptedException
      Wait until the Kompics runtime is shut down.

      Can not be used safely from within Kompics components.

      Throws:
      InterruptedException - if the waiting is interrupted
    • logStats

      @Deprecated public static void logStats()
      Deprecated.
      since 1.2.0, don't use the the @{link WorkStealingScheduler}!
      Log statistics if the @{link WorkStealingScheduler} is used.