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

Fixed the issues of takeLast(items, 0) and null values #413

Merged
merged 3 commits into from
Oct 9, 2013

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented Sep 29, 2013

Hi,

There are two issues about takeLast #85 #140. The essential cause is LinkedBlockingDeque.

  1. count == 0
    takeLast in RxJava will throw an exception when count == 0, as LinkedBlockingDeque rejects count <= 0. However, in c#, TakeLast with 0 count is valid. The following codes is OK in C# (no exception and do nothing):
            var source = Observable.Return(1).TakeLast(0);
            source.Subscribe(
                x => 
                    Console.WriteLine("subscriber got " + x)
            );
            Console.ReadLine();
  1. null values
    LinkedBlockingDeque requires the elements can not be null but an observable can emit a null value.

I used ReentrantLock and LinkedList to replace LinkedBlockingDeque. Please take a look. Thanks.

@cloudbees-pull-request-builder

RxJava-pull-requests #319 SUCCESS
This pull request looks good

@cloudbees-pull-request-builder

RxJava-pull-requests #321 SUCCESS
This pull request looks good

@benjchristensen
Copy link
Member

Merging as this seems correct ... but I question whether we need any of this synchronization in here since this operator would never be multi-threaded. It can count on the Rx contract to have sequential onNext events.

Thus I wonder if the performance hit of all this synchronization is a concern or necessary. I'm favoring functionality and merging now ... but something to consider for the future.

benjchristensen added a commit that referenced this pull request Oct 9, 2013
Fixed the issues of takeLast(items, 0) and null values
@benjchristensen benjchristensen merged commit 3e47103 into ReactiveX:master Oct 9, 2013
rickbw pushed a commit to rickbw/RxJava that referenced this pull request Jan 9, 2014
Fixed the issues of takeLast(items, 0) and null values
@zsxwing zsxwing deleted the take-last branch February 13, 2014 13:16
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.

3 participants