2022-03-01 15:19:01 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package pgp.cert_d;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
public interface LockingMechanism {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lock the store for writes.
|
|
|
|
* Readers can continue to use the store and will always see consistent certs.
|
2022-04-29 16:31:49 +02:00
|
|
|
*
|
|
|
|
* @throws IOException in case of an IO error
|
|
|
|
* @throws InterruptedException if the thread gets interrupted
|
2022-03-01 15:19:01 +01:00
|
|
|
*/
|
|
|
|
void lockDirectory() throws IOException, InterruptedException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try top lock the store for writes.
|
|
|
|
* Return false without locking the store in case the store was already locked.
|
|
|
|
*
|
|
|
|
* @return true if locking succeeded, false otherwise
|
2022-04-29 16:31:49 +02:00
|
|
|
*
|
|
|
|
* @throws IOException in case of an IO error
|
2022-03-01 15:19:01 +01:00
|
|
|
*/
|
|
|
|
boolean tryLockDirectory() throws IOException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release the directory write-lock acquired via {@link #lockDirectory()}.
|
2022-04-29 16:31:49 +02:00
|
|
|
*
|
|
|
|
* @throws IOException in case of an IO error
|
2022-03-01 15:19:01 +01:00
|
|
|
*/
|
|
|
|
void releaseDirectory() throws IOException;
|
|
|
|
|
|
|
|
}
|