FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-sdk/src/main/java/dev/openfeature/sdk/Awaitable.java at main · open-feature/java-sdk · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
open-feature
/
java-sdk
Public
Notifications
You must be signed in to change notification settings
Fork
60
Star
127
Code
Issues
13
Pull requests
16
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-sdk
/
src
/
main
/
java
/
dev
/
openfeature
/
sdk
/
Awaitable.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (37 loc) · 1.19 KB
Breadcrumbs
java-sdk
/
src
/
main
/
java
/
dev
/
openfeature
/
sdk
/
Awaitable.java
Copy path
File metadata and controls
44 lines (37 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package
dev
.
openfeature
.
sdk
;
/**
* A class to help with synchronization by allowing the optional awaiting of the associated action.
*/
public
class
Awaitable
{
/**
* An already-completed Awaitable. Awaiting this will return immediately.
*/
public
static
final
Awaitable
FINISHED
=
new
Awaitable
(
true
);
private
boolean
isDone
=
false
;
public
Awaitable
() {}
private
Awaitable
(
boolean
isDone
) {
this
.
isDone
=
isDone
;
}
/**
* Lets the calling thread wait until some other thread calls {@link Awaitable#wakeup()}. If
* {@link Awaitable#wakeup()} has been called before the current thread invokes this method, it will return
* immediately.
*/
@
SuppressWarnings
(
"java:S2142"
)
public
synchronized
void
await
() {
while
(!
isDone
) {
try
{
this
.
wait
();
}
catch
(
InterruptedException
ignored
) {
// ignored, do not propagate the interrupted state
}
}
}
/**
* Wakes up all threads that have called {@link Awaitable#await()} and lets them proceed.
*/
public
synchronized
void
wakeup
() {
isDone
=
true
;
this
.
notifyAll
();
}
}
Back
|
FazBrowse Home
|
New Git URL