You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm struggling to get this right. I have a SignalProducer that will send Quality of Service prediction values every 20 milliseconds. My requirements are:
Discard all the values sent during the first filteringTime seconds of every experiment.
Throttle the output to throttlingTime seconds.
Restart the signal producer every experimentDuration seconds.
Perform maxExperiments restarts, then complete.
This is my best approach for the moment:
func qualityOfServiceSignalProducer(filteringTime filteringTime:NSTimeInterval, throttlingTime:NSTimeInterval, maxExperiments:Int, experimentDuration:NSTimeInterval)->SignalProducer<QualityLevel,NoError>{letfilterTimerProducer=SignalProducer<(),NoError>{ sink, disposable inself.scheduler.scheduleAfter(self.scheduler.currentDate.dateByAddingTimeInterval(filteringTime)){
sink.sendCompleted()}}letendExperimentTimerProducer=SignalProducer<(),NoError>{ sink, disposable inself.scheduler.scheduleAfter(self.scheduler.currentDate.dateByAddingTimeInterval(experimentDuration)){
sink.sendCompleted()}}returnself.tesseractReactiveMonitor.forecastSignalProducer()//the signal producer that sends QoS predictions on start.skipUntil(filterTimerProducer).throttle(throttlingTime, onScheduler: scheduler).takeUntil(endExperimentTimerProducer).times(maxExperiments)}
What bothers me the most is to have to use these two timers, filterTimerProducer and endExperimentTimerProducer, in combination with takeUntil-like operators, which feels a little bit artificial. I wonder if there is a better approach using existing RAC operators.
My other concern is that RAC doesn't provide a skipUntil operator. Given the symmetry between:
take ~> skip
takeWhile ~> skipWhile
I was expecting to also have takeUntil ~> skipUntil. Perhaps I'm missing something and there is a better way to implement this skipUntil behavior with existing operators?
Anyway, I've created a skipUntil implementation by pretty much mimicking takeUntil in this commit: cesteban@fbf467c
I will send a pull request if you think this could be useful for anybody else. It is definitely useful for me unless anybody can suggest a better approach.
Thanks a lot. Any advice will be greatly appreciated.
The text was updated successfully, but these errors were encountered:
I was expecting to also have takeUntil ~> skipUntil. Perhaps I'm missing something and there is a better way to implement this skipUntil behavior with existing operators?
I will send a pull request if you think this could be useful for anybody else. It is definitely useful for me unless anybody can suggest a better approach
I agree, I think skipUntil can be considered a fundamental operator and therefore we should have it.
I took a quick look at your implementation and except for a couple of small things I think it looks great!
I'm struggling to get this right. I have a SignalProducer that will send Quality of Service prediction values every 20 milliseconds. My requirements are:
filteringTime
seconds of every experiment.throttlingTime
seconds.experimentDuration
seconds.maxExperiments
restarts, then complete.This is my best approach for the moment:
What bothers me the most is to have to use these two timers,
filterTimerProducer
andendExperimentTimerProducer
, in combination withtakeUntil
-like operators, which feels a little bit artificial. I wonder if there is a better approach using existing RAC operators.My other concern is that RAC doesn't provide a
skipUntil
operator. Given the symmetry between:take
~>skip
takeWhile
~>skipWhile
I was expecting to also have
takeUntil
~>skipUntil
. Perhaps I'm missing something and there is a better way to implement thisskipUntil
behavior with existing operators?Anyway, I've created a
skipUntil
implementation by pretty much mimickingtakeUntil
in this commit: cesteban@fbf467cI will send a pull request if you think this could be useful for anybody else. It is definitely useful for me unless anybody can suggest a better approach.
Thanks a lot. Any advice will be greatly appreciated.
The text was updated successfully, but these errors were encountered: