-
Notifications
You must be signed in to change notification settings - Fork 603
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
Topic/interrupt scope #1019
Merged
Merged
Topic/interrupt scope #1019
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4f9661a
Implemented interruption via Scope#Interrupt
pchlupacek e09177b
Fixed concurrently to not propagate Interrupt outside of its scope.
pchlupacek a9967d9
Added more test cases to test flatMapped hung streams to be interrupted
pchlupacek a85bead
Added resume interruption test
pchlupacek 8757ea2
Added more tests and corrected scope closure in flatMap
pchlupacek 750d062
Revereted flatMap implementation, introduced onInterrupt
pchlupacek c206629
Moved Interrupted to fs2._ root
pchlupacek 3cc0adb
Introduce id of the scope of the intterruption
pchlupacek a886ee6
Append based interruption
pchlupacek 2ab62d8
Introduced Algebra.Uncons
pchlupacek a53f8fc
Fixed issues uncovered in tests
pchlupacek 91cbb9f
Merge branch 'series/0.10' of github.com:functional-streams-for-scala…
pchlupacek 3b4e0d7
Corrected concurrently spec that `drained` the failed stream before c…
pchlupacek b2db70f
Implemented Run in terms of Segment.force.splitAt
pchlupacek 399deba
Added test to verify that #1035 is fixed
pchlupacek b522afb
Corrected name of spec cases
pchlupacek 73c27bc
Merge branch 'series/0.10' into topic/interrupt-scope
mpilquist dcca8ba
Merge branch 'series/0.10' into topic/interrupt-scope
mpilquist d68d7f8
Merge branch 'series/0.10' of github.com:functional-streams-for-scala…
pchlupacek 44a249c
Addressed review comments, cleanup
pchlupacek 6f64b36
Merge branch 'topic/interrupt-scope' of github.com:functional-streams…
pchlupacek 71ee481
Addresses review comments
pchlupacek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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,18 @@ | ||
package fs2 | ||
|
||
import fs2.internal.Token | ||
|
||
/** | ||
* Signals interruption of the evaluation. | ||
* | ||
* @param scopeId Id of the scope that shall be the last interrupted scope by this signal | ||
* @param loop In case of infinite recursion this prevents interpreter to search for `CloseScope` indefinitely. | ||
* In each recursive iteration, this will increment by 1 up to limit defined in current scope, | ||
* After which this will Interrupt stream w/o searching further for any cleanups. | ||
*/ | ||
final case class Interrupted(private[fs2] val scopeId: Token, private[fs2] val loop: Int) extends Throwable { | ||
override def fillInStackTrace = this | ||
|
||
override def toString = s"Interrupted($scopeId, $loop)" | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -1034,6 +1034,21 @@ object Segment { | |
result.get | ||
} | ||
|
||
/** | ||
* Like `run` but allows to run `f` for each `O`. | ||
* as they are processed when running this segment. | ||
* Allows to perfrom efficient accumulation of `O` while running the stream. | ||
*/ | ||
final def runForEach(f: O => Unit): R = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, could we change signature of def foreach(f: O => Unit): R Similar change for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. will do. |
||
def chunk(ch: Chunk[O]): Unit = ch.foreach(f) | ||
var result: Option[R] = None | ||
val trampoline = new Trampoline | ||
val step = self.stage(Depth(0), trampoline.defer, f, chunk, r => { result = Some(r); throw Done }).value | ||
try while (true) stepAll(step, trampoline) | ||
catch { case Done => } | ||
result.get | ||
} | ||
|
||
/** | ||
* Splits this segment at the specified index by simultaneously taking and dropping. | ||
* | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor style nitpick -- these comments can be either put in to the test name -- e.g.
intterupt (3) - interruption of constant stream
or wrapped in aninfo("interruption of constant stream")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about info syntax, can you just write quick example pls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just prints the info string to the test output in test reports. In this case, it's probably better in the test name itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have recently experimented with that, however info() causes to print out the text at every
Gen
case, so perhaps 100x or so for every test.I am not sure about moving test cases to the names, not sure what that will do with tools that using names of tests to filter execution of only one single test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Moving text description to test name works fine -- e.g.,
testOnly *MergeJoinSpec -- -z interrupt
will run all the tests that include the wordinterrupt
in their name