https://kotlinlang.org logo
#coroutines
Title
# coroutines
z

zak.taccardi

04/12/2019, 4:58 PM
if you use
actor.offer(message)
(instead of
actor.send(message)
when the
actor(capacity = Channel.UNLIMITED)
, is there locking involved?
my primary use case is that I want ensure delivery of the message, because the suspended
actor.send(message)
may get cancelled before delivery occurs. Think a
ViewModel#onCleared()
occurring which would cancel the scope in which
actor.send(..)
is called
d

Dominaezzz

04/12/2019, 5:17 PM
locking or blocking?
z

zak.taccardi

04/12/2019, 5:17 PM
locking
(I’m trying to write lock-free code)
d

Dominaezzz

04/12/2019, 5:18 PM
I don't think
kotlinx.coroutines
uses locks ever.
Take that with a grain of salt of course.
g

gildor

04/13/2019, 8:00 AM
I don't think that there is any locking with offer, an item will be added to lock-free queue
Also send to Unlimited channel should not work differently comparing to offer it would be mostly the same, because suspension point will return immediately
2 Views