Skip to content

[flagd] improve wait logic to a more elegant solution #1160

Closed
@aepfli

Description

@aepfli

Our current waiting logic could be improved. It is a working wait logic, but it might not be the most elegant solution.

public static void busyWaitAndCheck(final Long deadline, final Supplier<Boolean> connectedSupplier)
throws InterruptedException {
long start = System.currentTimeMillis();
do {
if (deadline <= System.currentTimeMillis() - start) {
throw new GeneralError(String.format(
"Deadline exceeded. Condition did not complete within the %d " + "deadline", deadline));
}
Thread.sleep(50L);
} while (!connectedSupplier.get());
}

This task aims to migrate to an approach with notify() and wait(). As suggested by @chrfwow within #1115.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions