Debian Codegraph @

jcstress-tests/src/main/java/org/eclipse/collections/impl/map/mutable/JucConcurrentHashMapEntrySetRemoveIfTest.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 java.util.Map;
14 import java.util.concurrent.ConcurrentHashMap;
15
16 import org.openjdk.jcstress.annotations.Actor;
17 import org.openjdk.jcstress.annotations.Arbiter;
18 import org.openjdk.jcstress.annotations.Expect;
19 import org.openjdk.jcstress.annotations.JCStressTest;
20 import org.openjdk.jcstress.annotations.Outcome;
21 import org.openjdk.jcstress.annotations.State;
22 import org.openjdk.jcstress.infra.results.Z_Result;
23
24 @JCStressTest
25 @Outcome(id = "false", expect = Expect.ACCEPTABLE)
26 @Outcome(expect = Expect.FORBIDDEN)
27 @State
28 public class JucConcurrentHashMapEntrySetRemoveIfTest
29 {
30 private final ConcurrentHashMap<Integer, Boolean> map = new ConcurrentHashMap<>();
31
32 @Actor
33 public void setFoo()
34 {
35 this.map.put(1, false);
36 }
37
38 @Actor
39 public void removeIf()
40 {
41 this.map.put(1, true);
42 this.map.entrySet().removeIf(Map.Entry::getValue);
43 }
44
45 @Arbiter
46 public void after(Z_Result r)
47 {
48 r.r1 = this.map.containsKey(1) && this.map.get(1);
49 }
50 }