Skip to content

WIP: OnSubscribeRefCount Synchronous #1754

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

Closed

Conversation

benjchristensen
Copy link
Member

This is a work in progress... do not merge or use this.

Submitting as PR to allow discussion.

@benjchristensen
Copy link
Member Author

This adds further unit tests for #1695 and tries an approach that doesn't block threads with locks and non-deterministically break the unit tests.

There are still issues with this code.

int count = subscriptionCount.getAndIncrement();
if (count == 0) {
// starting a new connection
final MultipleAssignmentSubscription connectableSubscriptionHolder = new MultipleAssignmentSubscription();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not thread-safe because 1 thread could be creating this subscription while a 2nd jumps ahead, registers its subscription then gets a null when it unsubscribes and blows up with an NPE all before the 1st thread finishes creating the MultipleAssignmentSubscription.

We either need locks or to use a State object with a single AtomicReference containing them all in a state machine.

@benjchristensen
Copy link
Member Author

I commented on the obvious problems in my code ... the real reason for this being shown is to make my unit tests available.

@benjchristensen
Copy link
Member Author

Closing so no one confuses this for a real PR.

@benjchristensen benjchristensen deleted the issue1688-refCount branch October 15, 2014 15: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.

1 participant