- java.lang.Object
-
- org.logicng.handlers.ComputationHandler
-
- org.logicng.handlers.TimeoutHandler
-
- All Implemented Interfaces:
Handler
- Direct Known Subclasses:
TimeoutBDDHandler,TimeoutMaxSATHandler,TimeoutModelEnumerationHandler,TimeoutOptimizationHandler,TimeoutSATHandler
public abstract class TimeoutHandler extends ComputationHandler
An abstract timeout handler.- Since:
- 1.6.2
- Version:
- 2.1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimeoutHandler.TimerTypeA timeout type determines how a timeout is interpreted.
-
Field Summary
Fields Modifier and Type Field Description protected longdesignatedEndprotected longtimeoutprotected TimeoutHandler.TimerTypetype-
Fields inherited from class org.logicng.handlers.ComputationHandler
aborted
-
-
Constructor Summary
Constructors Constructor Description TimeoutHandler(long timeout)Constructs a new abstract timeout handler with a given timeout and uses the timeout typeTimeoutHandler.TimerType.SINGLE_TIMEOUT.TimeoutHandler(long timeout, TimeoutHandler.TimerType type)Constructs a new abstract timeout handler with a given timeout and a timeout type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidstarted()This method is called when the computation starts.protected booleantimeLimitExceeded()Tests if the current time exceeds the timeout limit.-
Methods inherited from class org.logicng.handlers.ComputationHandler
aborted
-
-
-
-
Field Detail
-
timeout
protected long timeout
-
type
protected final TimeoutHandler.TimerType type
-
designatedEnd
protected long designatedEnd
-
-
Constructor Detail
-
TimeoutHandler
public TimeoutHandler(long timeout, TimeoutHandler.TimerType type)Constructs a new abstract timeout handler with a given timeout and a timeout type. The interpretation of the timeout depends on the timeout type:TimeoutHandler.TimerType.SINGLE_TIMEOUT: The timeout is started whenHandler.started()is called. Further calls toHandler.started()have no effect on the timeout. Thus, the timeout can only be started once.TimeoutHandler.TimerType.RESTARTING_TIMEOUT: The timeout is restarted whenHandler.started()is called.TimeoutHandler.TimerType.FIXED_END: Timeout which is interpreted as fixed point in time (in milliseconds) at which the computation should be aborted. The methodHandler.started()must still be called, but does not have an effect on the timeout.
- Parameters:
timeout- the timeout in milliseconds, its meaning is defined by the timeout typetype- the type of the timer, must not benull
-
TimeoutHandler
public TimeoutHandler(long timeout)
Constructs a new abstract timeout handler with a given timeout and uses the timeout typeTimeoutHandler.TimerType.SINGLE_TIMEOUT. Thus, the timeout is started whenHandler.started()is called and further calls toHandler.started()have no effect on the timeout.- Parameters:
timeout- the timeout in milliseconds
-
-
Method Detail
-
started
public void started()
Description copied from interface:HandlerThis method is called when the computation starts.- Specified by:
startedin interfaceHandler- Overrides:
startedin classComputationHandler
-
timeLimitExceeded
protected boolean timeLimitExceeded()
Tests if the current time exceeds the timeout limit.- Returns:
trueif the current time exceeds the timeout limit, otherwisefalse
-
-