-
Notifications
You must be signed in to change notification settings - Fork 751
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
Enhance AsyncLock to support passing state. #554
Enhance AsyncLock to support passing state. #554
Conversation
Up to discussion: Should the public API be enhanced and the new internal method be made public? |
I'm not convinced this is much of a win. the |
Right, structs would need to be boxed, but I found most of the time, if something would need to be passed to AsyncLock, it's a class. Besides, if creation of a closure and a delegate could be avoided, it's still a saving of one allocation if boxing occurs. |
So what's your proposal for a trampoline with state? Duplicate AsyncLock with a generic type parameter? |
Yes, don't penalize the stateless user places. |
That would work if all places in a class would only ever pass the same type of state. This might be the case in Rx but it would severely limit the usefulness of AsyncLock. Hence the object parameter. |
Why would it be public? Support Rx primarily, also T can be object. |
Will revisit after #558 is merged. |
@akarnokd Revised the approach. Boxing will still occur when TState is a value type, however, it's still an improvement over closure+delegate. |
No description provided.