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