Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save AtomicBoolean allocation in Arc #25032

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.enterprise.context.BeforeDestroyed;
Expand Down Expand Up @@ -168,7 +167,7 @@ public void destroy(ContextState state) {
}
if (state instanceof RequestContextState) {
RequestContextState reqState = ((RequestContextState) state);
reqState.isValid.set(false);
reqState.isValid = false;
synchronized (state) {
Map<Contextual<?>, ContextInstanceHandle<?>> map = ((RequestContextState) state).map;
// Fire an event with qualifier @BeforeDestroyed(RequestScoped.class) if there are any observers for it
Expand Down Expand Up @@ -228,11 +227,12 @@ private static Notifier<Object> createDestroyedNotifier() {
static class RequestContextState implements ContextState {

private final Map<Contextual<?>, ContextInstanceHandle<?>> map;
private final AtomicBoolean isValid;

private volatile boolean isValid;

RequestContextState(ConcurrentMap<Contextual<?>, ContextInstanceHandle<?>> value) {
this.map = Objects.requireNonNull(value);
this.isValid = new AtomicBoolean(true);
this.isValid = true;
}

@Override
Expand All @@ -243,7 +243,7 @@ public Map<InjectableBean<?>, Object> getContextualInstances() {

@Override
public boolean isValid() {
return isValid.get();
return isValid;
}

}
Expand Down