Skip to content

add capture-checked scala.concurrent standard library classes #23089

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -294,5 +294,5 @@ object ExecutionContext {
*
* @return the function for error reporting
*/
final val defaultReporter: Throwable => Unit = _.printStackTrace()
final val defaultReporter: Throwable -> Unit = _.printStackTrace()
}
10 changes: 5 additions & 5 deletions scala2-library-cc/src/scala/concurrent/impl/Promise.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ private[concurrent] object Promise {
/**
* Compresses this chain and returns the currently known root of this chain of Links.
**/
final def promise(owner: DefaultPromise[T]^): DefaultPromise[T]^{cap.rd, this, to, owner} = {
final def promise(owner: DefaultPromise[T]^): DefaultPromise[T]^{to, owner} = {
val c = get()
compressed(current = c, target = c, owner = owner)
}

/**
* The combination of traversing and possibly unlinking of a given `target` DefaultPromise.
**/
@inline @tailrec private[this] final def compressed(current: DefaultPromise[T]^{cap.rd, this}, target: DefaultPromise[T]^, owner: DefaultPromise[T]^): DefaultPromise[T]^{this, current, target, owner} = {
@inline @tailrec private[this] final def compressed(current: DefaultPromise[T]^{this, to}, target: DefaultPromise[T]^{cap, this, current}, owner: DefaultPromise[T]^): DefaultPromise[T]^{to, target, owner} = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look into this more, I tried simplifying this signature but it seems separation checker is not trying to shorten paths

val value = target.get()
if (value.isInstanceOf[Callbacks[_]]) {
if (compareAndSet(current, target)) target // Link
Expand Down Expand Up @@ -151,7 +151,7 @@ private[concurrent] object Promise {
val buffer = new AtomicReference[Success[Any]]()
val zipped = new DefaultPromise[R]()

val thisF: Try[T] => Unit = {
val thisF: Try[T] ->{f} Unit = {
case left: Success[_] =>
val right = buffer.getAndSet(left).asInstanceOf[Success[U]]
if (right ne null)
Expand All @@ -160,7 +160,7 @@ private[concurrent] object Promise {
zipped.tryComplete(f.asInstanceOf[Failure[R]])
}

val thatF: Try[U] => Unit = {
val thatF: Try[U] ->{f} Unit = {
case right: Success[_] =>
val left = buffer.getAndSet(right).asInstanceOf[Success[T]]
if (left ne null)
Expand Down Expand Up @@ -349,7 +349,7 @@ private[concurrent] object Promise {

/** Link this promise to the root of another promise.
*/
@tailrec private[concurrent] final def linkRootOf(target: DefaultPromise[T]^, link: Link[T]^): Unit =
@tailrec private[concurrent] final def linkRootOf(target: DefaultPromise[T]^, link: Link[T]^{cap, target}): Unit =
if (this ne target) {
val state = get()
if (state.isInstanceOf[Try[_]]) {
Expand Down
Loading