Debian Codegraph @

jcstress-tests/src/main/java/org/eclipse/collections/impl/map/mutable/ConcurrentHashMapValuesRemoveIfTest.java

raw
1 /*
2 * Copyright (c) 2021 Ivan Sopov and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and Eclipse Distribution License v. 1.0 which accompany this distribution.
6 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7 * and the Eclipse Distribution License is available at
8 * http://www.eclipse.org/org/documents/edl-v10.php.
9 */
10
11 package org.eclipse.collections.impl.map.mutable;
12
13 import org.openjdk.jcstress.annotations.Actor;
14 import org.openjdk.jcstress.annotations.Arbiter;
15 import org.openjdk.jcstress.annotations.Expect;
16 import org.openjdk.jcstress.annotations.JCStressTest;
17 import org.openjdk.jcstress.annotations.Outcome;
18 import org.openjdk.jcstress.annotations.State;
19 import org.openjdk.jcstress.infra.results.Z_Result;
20
21 @JCStressTest
22 @Outcome(id = "false", expect = Expect.ACCEPTABLE)
23 @Outcome(expect = Expect.FORBIDDEN)
24 @State
25 public class ConcurrentHashMapValuesRemoveIfTest
26 {
27 private final ConcurrentHashMap<Integer, Boolean> map = new ConcurrentHashMap<>();
28
29 @Actor
30 public void setFoo()
31 {
32 this.map.put(1, false);
33 }
34
35 @Actor
36 public void removeIf()
37 {
38 this.map.put(1, true);
39 this.map.values().removeIf(Boolean::valueOf);
40 }
41
42 @Arbiter
43 public void after(Z_Result r)
44 {
45 r.r1 = this.map.containsKey(1) && this.map.get(1);
46 }
47 }