Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Small Queue improvements #235

Merged
merged 6 commits into from
Jul 30, 2020
Merged

Small Queue improvements #235

merged 6 commits into from
Jul 30, 2020

Conversation

nomisRev
Copy link
Member

@nomisRev nomisRev commented Jul 29, 2020

Couple of small improvements to Queue.

  • Remove suspend from tryOffer and signal using Boolean instead to interopt from non-suspend code
  • Unsafe constructors for PubSub and Queue.

@@ -32,7 +32,7 @@ internal interface Publish<A> {
* Evaluates to `false` if element was not published.
* Evaluates to `true` if element was published successfully.
*/
suspend fun tryPublish(a: A): Boolean
fun tryPublish(a: A): Boolean
Copy link
Member

Choose a reason for hiding this comment

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

Why was it suspend?

Copy link
Member Author

@nomisRev nomisRev Jul 29, 2020

Choose a reason for hiding this comment

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

Because the underlying implementation was still relying on suspension, which has now been rewritten to work without suspension.

EDIT: it was sharing code with suspend fun publish.

@@ -39,7 +39,7 @@ interface Enqueue<A> {
*
* @param a `A` to enqueue
*/
suspend fun offer1(a: A): Boolean
fun tryOffer1(a: A): Boolean
Copy link
Member Author

Choose a reason for hiding this comment

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

@JorgeCastilloPrz breaking change in Arrow Fx Coroutine Stream's Queue.

/** Creates a FILO queue with the specified size bound. */
suspend fun <A> boundedLife(maxSize: Int): Queue<A> =
Copy link
Member Author

Choose a reason for hiding this comment

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

@JorgeCastilloPrz Second breaking change

@nomisRev nomisRev marked this pull request as ready for review July 29, 2020 12:06
Copy link
Contributor

@danimontoya danimontoya left a comment

Choose a reason for hiding this comment

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

🙌

@@ -39,7 +39,7 @@ interface Enqueue<A> {
*
* @param a `A` to enqueue
*/
suspend fun offer1(a: A): Boolean
fun tryOffer1(a: A): Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

that was fast!! thank youu!! 🎉

@aballano aballano merged commit 78f8e34 into master Jul 30, 2020
@aballano aballano deleted the sv-small-queue-improvements branch July 30, 2020 14:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants