Skip to content
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

Introduce FlattenStrategy.concurrent. #298

Merged
merged 7 commits into from
Mar 31, 2017
Merged

Introduce FlattenStrategy.concurrent. #298

merged 7 commits into from
Mar 31, 2017

Conversation

andersio
Copy link
Member

@andersio andersio commented Mar 28, 2017

Implements #297.

concat and merge are now aliases of concurrent(limit: 1) and concurrent(limit: .max), respectively. The iterative process to start producers is preserved.

WIP:

  • Test cases for the new "merge up to N producers at any point of time" behaviour.

@andersio andersio added this to the 2.0 milestone Mar 28, 2017
@@ -389,10 +395,11 @@ extension SignalProtocol where Value: SignalProducerProtocol, Error == Value.Err
}
}
}
state.modify { $0.isStarting = false }

isStarting = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Is assigning to a Bool an atomic operation? This write could happen concurrently with the read above. I think it needs to at least be in its own Atomic.

@mdiep
Copy link
Contributor

mdiep commented Mar 28, 2017

Test cases for concurrent(limit: 0), which would queue all inner producers indefinitely until the outer producer terminates.

I'm not sure that makes sense. Maybe we just add a precondition that count must be >0?

$0.active = nil
return !$0.isStarting
handle.remove()
_ = cleanup
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this enough to guarantee that producerState remains initialized until after both the read and the write?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Its lifetime is limited by the closure or the while loop body scope, whichever is longer.

@NachoSoto
Copy link
Member

Do we have a way to test for regressions in performance/memory in .concat?

@mdiep
Copy link
Contributor

mdiep commented Mar 28, 2017

Looking at it, I'm not sure why this would cause any performance issues. The code is basically the same.

But I'm sure @andersio could run some benchmarks.

@mdiep
Copy link
Contributor

mdiep commented Mar 29, 2017

It looks like those tests don't compile on Linux.

$0.active = nil
return !$0.isStarting
}
withExtendedLifetime(deinitializer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could probably surround just the producerState.setStarted() below?

Copy link
Member Author

Choose a reason for hiding this comment

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

True,

@mdiep mdiep merged commit 3739bea into master Mar 31, 2017
@mdiep mdiep deleted the concurrent-strategy branch March 31, 2017 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants