-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize standard library collections under cc (#18858)
1. Revert previous merge commit 2. Add all changes to capture tracking in the compiler to make (4) go through. 3. Add all collection classes without changes to test directory in one commit [3caf116](3caf116). 4. Add all changes to collection classes made for capture checking in another commit [b5bfbab](b5bfbab).
- Loading branch information
Showing
27 changed files
with
4,727 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
tests/pos-special/stdlib/collection/concurrent/BasicNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.collection.concurrent; | ||
|
||
public abstract class BasicNode { | ||
|
||
public abstract String string(int lev); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
tests/pos-special/stdlib/collection/concurrent/CNodeBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.collection.concurrent; | ||
|
||
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; | ||
|
||
abstract class CNodeBase<K, V> extends MainNode<K, V> { | ||
|
||
@SuppressWarnings("unchecked") | ||
public static final AtomicIntegerFieldUpdater<CNodeBase<?, ?>> updater = | ||
AtomicIntegerFieldUpdater.newUpdater((Class<CNodeBase<?, ?>>) (Class<?>) CNodeBase.class, "csize"); | ||
|
||
public volatile int csize = -1; | ||
|
||
public boolean CAS_SIZE(int oldval, int nval) { | ||
return updater.compareAndSet(this, oldval, nval); | ||
} | ||
|
||
public void WRITE_SIZE(int nval) { | ||
updater.set(this, nval); | ||
} | ||
|
||
public int READ_SIZE() { | ||
return updater.get(this); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.collection.concurrent; | ||
|
||
final class Gen {} |
39 changes: 39 additions & 0 deletions
39
tests/pos-special/stdlib/collection/concurrent/INodeBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.collection.concurrent; | ||
|
||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; | ||
|
||
abstract class INodeBase<K, V> extends BasicNode { | ||
|
||
@SuppressWarnings("unchecked") | ||
public static final AtomicReferenceFieldUpdater<INodeBase<?, ?>, MainNode<?, ?>> updater = | ||
AtomicReferenceFieldUpdater.newUpdater((Class<INodeBase<?, ?>>) (Class<?>) INodeBase.class, (Class<MainNode<?, ?>>) (Class<?>) MainNode.class, "mainnode"); | ||
|
||
static final Object RESTART = new Object(); | ||
|
||
static final Object NO_SUCH_ELEMENT_SENTINEL = new Object(); | ||
|
||
public volatile MainNode<K, V> mainnode = null; | ||
|
||
public final Gen gen; | ||
|
||
public INodeBase(Gen generation) { | ||
gen = generation; | ||
} | ||
|
||
public BasicNode prev() { | ||
return null; | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
tests/pos-special/stdlib/collection/concurrent/MainNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Scala (https://www.scala-lang.org) | ||
* | ||
* Copyright EPFL and Lightbend, Inc. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (http://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package scala.collection.concurrent; | ||
|
||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; | ||
|
||
abstract class MainNode<K, V> extends BasicNode { | ||
|
||
@SuppressWarnings("unchecked") | ||
public static final AtomicReferenceFieldUpdater<MainNode<?, ?>, MainNode<?, ?>> updater = | ||
AtomicReferenceFieldUpdater.newUpdater((Class<MainNode<?, ?>>) (Class<?>) MainNode.class, (Class<MainNode<?, ?>>) (Class<?>) MainNode.class, "prev"); | ||
|
||
public volatile MainNode<K, V> prev = null; | ||
|
||
public abstract int cachedSize(Object ct); | ||
|
||
// standard contract | ||
public abstract int knownSize(); | ||
|
||
public boolean CAS_PREV(MainNode<K, V> oldval, MainNode<K, V> nval) { | ||
return updater.compareAndSet(this, oldval, nval); | ||
} | ||
|
||
public void WRITE_PREV(MainNode<K, V> nval) { | ||
updater.set(this, nval); | ||
} | ||
|
||
// do we need this? unclear in the javadocs... | ||
// apparently not - volatile reads are supposed to be safe | ||
// regardless of whether there are concurrent ARFU updates | ||
@Deprecated @SuppressWarnings("unchecked") | ||
public MainNode<K, V> READ_PREV() { | ||
return (MainNode<K, V>) updater.get(this); | ||
} | ||
|
||
} |
Oops, something went wrong.