forked from open-feature/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add rw locks to client/api, hook accessor name (open-feature#131)
* fix: add read/write locks to client/api Signed-off-by: Todd Baert <[email protected]> * dont lock entire evaluation Signed-off-by: Todd Baert <[email protected]> * add tests Signed-off-by: Todd Baert <[email protected]> * fixup comment Signed-off-by: Todd Baert <[email protected]> * fixup pom comment Signed-off-by: Todd Baert <[email protected]> * increase lock granularity, imporove tests Signed-off-by: Todd Baert <[email protected]> * fix spotbugs Signed-off-by: Todd Baert <[email protected]> * remove commented test Signed-off-by: Todd Baert <[email protected]> Signed-off-by: Todd Baert <[email protected]> Signed-off-by: Bhandari, Pramesh(AWF) <[email protected]>
- Loading branch information
Showing
12 changed files
with
379 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/dev/openfeature/sdk/internal/AutoCloseableLock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dev.openfeature.sdk.internal; | ||
|
||
public interface AutoCloseableLock extends AutoCloseable { | ||
|
||
/** | ||
* Override the exception in AutoClosable. | ||
*/ | ||
@Override | ||
void close(); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/dev/openfeature/sdk/internal/AutoCloseableReentrantReadWriteLock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.openfeature.sdk.internal; | ||
|
||
import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
|
||
/** | ||
* A utility class that wraps a multi-read/single-write lock construct as AutoCloseable, so it can | ||
* be used in a try-with-resources. | ||
*/ | ||
public class AutoCloseableReentrantReadWriteLock extends ReentrantReadWriteLock { | ||
|
||
/** | ||
* Get the single write lock as an AutoCloseableLock. | ||
* @return unlock method ref | ||
*/ | ||
public AutoCloseableLock writeLockAutoCloseable() { | ||
this.writeLock().lock(); | ||
return this.writeLock()::unlock; | ||
} | ||
|
||
/** | ||
* Get the multi read lock as an AutoCloseableLock. | ||
* @return unlock method ref | ||
*/ | ||
public AutoCloseableLock readLockAutoCloseable() { | ||
this.readLock().lock(); | ||
return this.readLock()::unlock; | ||
} | ||
} |
Oops, something went wrong.