-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make ConflatedBroadcastChannel allocation-free (#395) #402
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
Conversation
Some issue with I will use a copy-on-write subscriptions list. |
f0f19f8
to
345aa68
Compare
I haven't carefully read your solution yet, so can't say whether your approach works in general, but here are a few pointers anyway:
|
Hi @qwwdfsad
can you confirm? Should them be added?
|
345aa68
to
d8f2a44
Compare
On 8-cores i7.
|
Binary compatibility issue can be ignored, please delete these lines from General issues:
Observations: Also note, that it doesn't fixe #395 completely, it just eliminates allocation of |
Hi @qwwdfsad I found the However I have some doubts, can I share these?
If So
Unfortunately between step 3 and 4 an entire Have you some other suggestion? |
d8f2a44
to
fbbf196
Compare
Hi @qwwdfsad |
Hi @fvasco, sorry for the delay. While reviewing your solution I've found that current (from I need some time to think about the importance of linearizability here and possible solutions and depending on that modify your PR, but unfortunately it's not in my major priority list right now (spoiler alert: native coroutines are incoming), so I should postpone this PR for a while, sorry :( |
Hi @qwwdfsad Using this new method we can define public override fun openSubscription(): ReceiveChannel<E> {
val subscriber = Subscriber()
_subscribers.add(subscriber)
val state = _state
@Suppress("UNCHECKED_CAST")
when {
state is Closed -> subscriber.close(state.closeCause)
state !== UNDEFINED -> subscriber.initialize(state as E)
}
if (subscriber.isClosedForSend) _subscribers.remove(subscriber)
return subscriber
} Using the |
Hi, Also, please add |
0c6de5a
to
6057b54
Compare
I don't understand how, |
You can use |
Hi @qwwdfsad, |
Sure, take your time. |
6057b54
to
46f2356
Compare
Hi @qwwdfsad, All Can you offer me another hint, a code snippet or, if you wish, put a your commit on this PR? |
69dc390
to
eaf9b7c
Compare
bc68d63
to
3179683
Compare
I apologize for letting it hang; I will work on my PR reviewing policy. I am not ready to spend your and my time on this PR now: we currently have a major rework of channels that will completely mess the implementation and in parallel, we'd want to implement #736 somehow. |
I will try to contribute on future work, thank you for your effort. |
openSubscription
,offer
andsend
are O(n) where n is subscriptions count.All
synchronized
block are allocation free.Closed subscriptions are not eligible to GC, a invocation to
openSubscription
,offer
,send
,cancel
orclose
is required.Fixes #395