Package io.keikai.model.util
Class ReadWriteTask<T>
- java.lang.Object
-
- io.keikai.model.util.ReadWriteTask<T>
-
public abstract class ReadWriteTask<T> extends Object
Use this class to help you concurrently access book model safely. Usage: implement your model-accessing logic in invoke() method.- Since:
- 3.5.0
- Author:
- dennis
-
-
Constructor Summary
Constructors Constructor Description ReadWriteTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
doInReadLock(ReadWriteLock lock)
Call invoke() after acquiring a read lock, and then release it.T
doInWriteLock(ReadWriteLock lock)
Call invoke() after acquiring a write lock, and then release it.abstract T
invoke()
The method will be invoked after acquiring a read-write lock and release the lock after invocation.
-
-
-
Method Detail
-
invoke
public abstract T invoke()
The method will be invoked after acquiring a read-write lock and release the lock after invocation. So implement your model-accessing logic in this method.- Returns:
- depends on your logic
-
doInWriteLock
public T doInWriteLock(ReadWriteLock lock)
Call invoke() after acquiring a write lock, and then release it.
-
doInReadLock
public T doInReadLock(ReadWriteLock lock)
Call invoke() after acquiring a read lock, and then release it.
-
-