-
Notifications
You must be signed in to change notification settings - Fork 430
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
Unserialized and Reentrant Signal
s
#797
Conversation
7e1422a
to
924a55b
Compare
924a55b
to
f0ac694
Compare
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 think this will be a nice improvement, thanks!
I'd like to take a deeper look at the code, but for now I did a quick scan for API naming. Wondering what you think about using the term unserialized instead of non-serializing, which reads awkwardly to me.
The terms introduced to our public API here a subtle, so I also left a suggestion that we could perhaps document them in a glossary of sorts to get a very clear definition that we can point to for decisions about where one makes more sense than the other. I'd also like to have a think about whether there's a better term to use than "unserialized".
@@ -200,6 +200,51 @@ class SignalSpec: QuickSpec { | |||
} | |||
} | |||
|
|||
describe("reentrant") { | |||
#if arch(x86_64) && canImport(Darwin) |
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.
What's the reason for restricting this text to x86?
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.
Catching deadlock by intercepting signals is supported only in iOS simulators.
https://github.com/mattgallagher/CwlPreconditionTesting#cwlpreconditiontesting
A Mach exception handler, written in Swift and Objective-C, that allows EXC_BAD_INSTRUCTION (as raised by Swift's assertionFailure/preconditionFailure/fatalError) to be caught and tested.
NOTE: the iOS code runs in the simulator only. It is for logic testing and cannot be deployed to the device due to the Mach exception API being private on iOS.
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.
What about Macs with an M1?
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 is more a question for Nimble/CwlPreconditionSignal. If they support catching signals on arm64/M1, we can lift this.
Signal
sSignal
s
Any update on when this might get merged @andersio ? |
Signal
now offers an unserialized variant and a reentrant variant for advanced users. (Unserialized and ReentrantSignal
s #797)These new primitives would be adopted by ReactiveCocoa UIKit bindings to improve interoperability with RAC Loop, to tackle some legitimate recursive delivery scenarios (e.g. around first responder management), and also to reduce fine-grained locking across ReactiveSwift and ReactiveCocoa.
Note that the default behavior of
Signal
has not been changed — event serialization remains the default behavior.MutableProperty
is also not gonna be reentrant, because there is no sane reentrancy model that supports access to the current value and multicasting while being compliant to the Property contract.Fine-grained locking has been scaled down across Signal, SignalProducer and Property. (Unserialized and Reentrant
Signal
s #797)Observers are naturally inheriting mutual exclusion from upstream, because the upstream has to serialize the events to be compliant to the Event contract. So for most transformations involving only one event stream (Signal/Producer), the locks for serializing events are redundant. This is also the same premise that RAS 2.0 producer optimizations are built upon.
This similarly applies to Properties — both the read-only and the mutable versions have their own locks for mutual exclusion. So for them, the only value which the default event serialization in
Signal
/SignalProducer
brings is wasting CPU time.Checklist