Class AbstractConcurrentService
java.lang.Object
ru.progrm_jarvis.javacommons.service.AbstractConcurrentService
- All Implemented Interfaces:
AutoCloseable,Service
Abstract implementation of
Service making its concurrent.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final @NonNull AtomicBooleanFlag indicating whether this service is enabledprotected final @NonNull LockLock used for synchronizing lifecycle operations -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConcurrentService(@NonNull Lock lifecycleLock) Creates a new abstract concurrent service using the given lock. -
Method Summary
Modifier and TypeMethodDescriptionvoiddisable()Disables this service, doing nothing if this service is already disabled.voidenable()Enables this service, doing nothing if this service is already enabled.protected abstract voidActually disables this service.protected abstract voidonEnable()Actually enables this service.
-
Field Details
-
enabled
Flag indicating whether this service is enabled -
lifecycleLock
Lock used for synchronizing lifecycle operations
-
-
Constructor Details
-
AbstractConcurrentService
Creates a new abstract concurrent service using the given lock.- Parameters:
lifecycleLock- lock used for synchronizing lifecycle operations
-
-
Method Details
-
enable
public void enable()Description copied from interface:ServiceEnables this service, doing nothing if this service is already enabled. -
onEnable
protected abstract void onEnable()Actually enables this service. This should not be manually synchronized as it is called by an already concurrentenable(). -
disable
public void disable()Description copied from interface:ServiceDisables this service, doing nothing if this service is already disabled. -
onDisable
protected abstract void onDisable()Actually disables this service. This should not be manually synchronized as it is called by an already concurrentdisable()()}.
-