Interface Synchronizer
-
- All Known Implementing Classes:
NoOpSynchronizer,ReadWriteSynchronizer
public interface Synchronizer
An interface controlling synchronization of configuration instances.
Each
Configurationobject derived fromAbstractConfigurationhas an associatedSynchronizerobject. Before an operation on the configuration is performed (e.g. a property read or an update), theSynchronizeris invoked. Depending on the concrete implementation of theSynchronizerused, the configuration can be made thread-safe.Whether a configuration has to be thread-safe or not is a matter of a concrete use case. For instance, an application that just reads some configuration settings on startup does need a thread-safe configuration implementation. A configuration in contrast which is shared between multiple components and updated concurrently should better be thread-safe. In order to satisfy both kinds of use cases, the support for thread-safety has been extracted out of the configuration implementation and refactored into this
Synchronizerinterface. By assigning differentSynchronizerimplementations to a configuration instance, the instance's support for concurrent access can be adapted to the concrete use case.The methods defined by this interface are similar to a read-write lock. The
Synchronizeris notified when read or write operations start and end. A concrete implementation can then apply a specific policy to decide when threads need to block or when access to the configuration for the desired operation is granted.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbeginRead()Notifies thisSynchronizerthat the current thread is going to start a read operation on the managed configuration.voidbeginWrite()Notifies thisSynchronizerthat the current thread is going to start a write operation on the managed configuration.voidendRead()Notifies thisSynchronizerthat the current thread has finished its read operation.voidendWrite()Notifies thisSynchronizerthat the current thread has finished its write operation.
-
-
-
Method Detail
-
beginRead
void beginRead()
Notifies thisSynchronizerthat the current thread is going to start a read operation on the managed configuration. This call can block if a concrete implementation decides that the thread has to wait until a specific condition is fulfilled.
-
endRead
void endRead()
Notifies thisSynchronizerthat the current thread has finished its read operation. This may cause other waiting threads to be granted access to the managed configuration.
-
beginWrite
void beginWrite()
Notifies thisSynchronizerthat the current thread is going to start a write operation on the managed configuration. This call may block. For instance, a concrete implementation may suspend the thread until all read operations currently active are finished,
-
endWrite
void endWrite()
Notifies thisSynchronizerthat the current thread has finished its write operation. This may cause other waiting threads to be granted access to the managed configuration.
-
-