Package se.sics.kompics
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 Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
logger
static AtomicInteger
maxNumOfExecutedEvents
static long
SHUTDOWN_TIMEOUT
-
Method Summary
Modifier and Type Method Description static void
asyncShutdown()
Asynchronously shut down the Kompics runtime.static <C extends ComponentDefinition>
voidcreateAndStart(Class<C> main)
Creates the top-level component and starts it together with the Kompics runtime.static <C extends ComponentDefinition>
voidcreateAndStart(Class<C> main, int workers)
Creates the top-level component and starts it together with the Kompics runtime.static <C extends ComponentDefinition>
voidcreateAndStart(Class<C> main, int workers, int maxEventExecuteNumber)
Creates the top-level component and starts it together with the Kompics runtime.static <C extends ComponentDefinition>
voidcreateAndStart(Class<C> main, Init<C> initEvent)
Creates the top-level component and starts it together with the Kompics runtime.static <C extends ComponentDefinition>
voidcreateAndStart(Class<C> main, Init<C> initEvent, int workers)
Creates the top-level component and starts it together with the Kompics runtime.static <C extends ComponentDefinition>
voidcreateAndStart(Class<C> main, Init<C> initEvent, int workers, int maxEventExecuteNumber)
Creates the top-level component and starts it together with the Kompics runtime.static void
forceShutdown()
Force an immediate shutdown of the Kompics runtime.static Config
getConfig()
Get the top-level config instance.static FaultHandler
getFaultHandler()
Get the root fault handler.static Scheduler
getScheduler()
Get the current Kompics runtime scheduler.static boolean
isOn()
Checks if the Kompics runtime is currently running.static void
logStats()
Deprecated.since 1.2.0, don't use the the @{link WorkStealingScheduler}!static void
resetConfig()
Reset the root config to the default value.static void
resetFaultHandler()
Reset the root fault handler to its default.static void
setConfig(Config conf)
Set the root config to the default value.static void
setFaultHandler(FaultHandler fh)
Set the root fault handler to its default.static void
setScheduler(Scheduler sched)
Set the Kompics runtime scheduler.static void
shutdown()
Synchronously shut down the Kompics runtime.static void
waitForTermination()
Wait until the Kompics runtime is shut down.
-
Field Details
-
Method Details
-
setScheduler
Set the Kompics runtime scheduler.- Parameters:
sched
- the scheduler to set- Throws:
RuntimeException
- if the Kompics runtime is already running
-
getScheduler
Get the current Kompics runtime scheduler.- Returns:
- the current scheduler
-
setFaultHandler
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
Reset the root fault handler to its default.- Throws:
RuntimeException
- if the Kompics runtime is already running
-
getFaultHandler
Get the root fault handler.- Returns:
- the root fault handler
-
setConfig
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
Reset the root config to the default value.- Throws:
RuntimeException
- if the Kompics runtime is already running
-
getConfig
Get the top-level config instance. Will load a default config, if none was set before.- Returns:
- the root config
-
isOn
Checks if the Kompics runtime is currently running.- Returns:
- true, if its running
-
createAndStart
Creates the top-level component and starts it together with the Kompics runtime. The valueInit.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 componentinitEvent
- the init event to pass to the root component
-
createAndStart
Creates the top-level component and starts it together with the Kompics runtime. The valueInit.NONE
is passed to the root component.- Type Parameters:
C
- the type of the root component- Parameters:
main
- the class instance of the root componentworkers
- 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 valueInit.NONE
is passed to the root component.- Type Parameters:
C
- the type of the root component- Parameters:
main
- the class instance of the root componentinitEvent
- the init event to pass to the root componentworkers
- 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 valueInit.NONE
is passed to the root component.- Type Parameters:
C
- the type of the root component- Parameters:
main
- the class instance of the root componentworkers
- the number of workers to use in the runtime's threadpoolmaxEventExecuteNumber
- 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 valueInit.NONE
is passed to the root component.- Type Parameters:
C
- the type of the root component- Parameters:
main
- the class instance of the root componentinitEvent
- the init event to pass to the root componentworkers
- the number of workers to use in the runtime's threadpoolmaxEventExecuteNumber
- the maximum number of events to execute before forcing a rescheduling of a component
-
asyncShutdown
Asynchronously shut down the Kompics runtime.Can be used safely from within components.
-
shutdown
Synchronously shut down the Kompics runtime.Can not be used safely from within Kompics components. Use
asyncShutdown()
instead. -
forceShutdown
Force an immediate shutdown of the Kompics runtime.Can not be used safely from within Kompics components.
-
waitForTermination
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.since 1.2.0, don't use the the @{link WorkStealingScheduler}!Log statistics if the @{link WorkStealingScheduler} is used.
-