groostav
08/07/2018, 12:12 AMkotlinx.coroutines.experimental.internal.LockFreeLinkedListHead
and friends? I'm using AtomicReference
with immutable classes and its working, but at this point I'm now asking my getAndUpdate
call to allocate a lot of new data in its `update`er method.
some notes:
- yes I know that class isnt formally part of the API, I will update as appropriate, and either copy-paste that code or keep everything at version zero.
- my existing solution probably would be fine if kotlinx.collections.immutable
was part of the stdlib, or I wanted to include it as an external dep, but its not, and I don't, and it seems to have lost all steam, much to my shigrin
- no, I dont want to use atomicfu
because I dont understand what atomicfu is asking me to do to my build system, ill poke around at gradle + byte code manipulation later.v0ldem0rt
08/07/2018, 12:35 AMbdawg.io
08/07/2018, 7:17 PMbdawg.io
08/07/2018, 7:31 PMN
thread coroutine context with a N
sized pooled data source?pavel
08/07/2018, 9:26 PMclose()
as I am reading the docs https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-send-channel/close.htmlgroostav
08/09/2018, 9:41 AMUnconfined
dispatcher in your map
function, I think this will get your outer deferred running on the inner deferred's thread, which might make this a bit more straight forward to debuguli
08/09/2018, 12:54 PMa
shared somewhere else, where it could be reset to null?groostav
08/09/2018, 6:51 PMEverything happening inside the async should be visible to everything happening after the asyncMy reading of java concurrency in practice is that this is not accurate
groostav
08/09/2018, 6:54 PMval notThreadSafe: Int? = null
fun doStuff() = runBlocking {
val updateJob = launch(CommonPool) { notThreadSafe = 1 }
updateJob.join()
val result = notThreadSafe // <- no gaurentee this isnt null, in fact theres no gaurentee that your thread will _ever_ see the value `1` on that field.
}
this is true despite happens before semantics. the assignment of 1
to notThreadSafe
happens before the assignment of notThreadSafe
to result
, but because its not marked as @Volatile
you have no gaurentees about when the value notTHreadSafe
will actually be written to main memory. Your only gaurentee is that all downstream operations on that thread on the common pool will see the value 1
for not thread safe.
I could be mistaken. Java Concurrency in Practice is a uniquely horrifying book to read.mp
08/09/2018, 7:40 PMSeri
08/09/2018, 7:52 PMSeri
08/09/2018, 9:10 PMigorvd
08/10/2018, 5:18 PMwhile (isActive)
with a delay. Is this the best approach?v0ldem0rt
08/11/2018, 5:22 AMPaul Woitaschek
08/13/2018, 2:16 PMelizarov
08/13/2018, 5:01 PMAtomic*FieldUpdater
Java APIs which leads to crashes with kotlinx.coroutines
. Do you know more details? How shall we work around this problem? You opinion is welcome here: https://github.com/Kotlin/kotlinx.coroutines/issues/490v0ldem0rt
08/13/2018, 5:13 PMAlbert
08/14/2018, 12:02 PMasync { ... http request ... }
at some point I am hitting connection refused, because the other end can not keep up.withoutclass
08/14/2018, 2:06 PMRuckus
08/14/2018, 5:11 PMbj0
08/14/2018, 5:16 PMbdawg.io
08/14/2018, 5:19 PMval result = async(myContext) { doSomething() }.await()
// vs
val result = withContext(myContext) { doSomething() }
v0ldem0rt
08/14/2018, 5:56 PMv0ldem0rt
08/15/2018, 3:25 AMDALDEI
08/15/2018, 10:25 PMalex.tavella
08/17/2018, 11:52 AMtianhao
08/19/2018, 11:19 PMelizarov
08/20/2018, 7:39 AMlouiscad
08/20/2018, 8:22 AMchannelA: Channel<A>
and channelB: Channel<B>
, I want to call a method like update(a: A, b: B)
each time I get a value from any channel, that is, if I receive from channelA
, I want it to be called with the new A
value, and the same B
value as previously received.
Each time I have a use case for it, I feel like I'm writing disposable/throwaway code that is a bit error-prone and quite boilerplate-y. If you have any clue about a solution to do it right once for all, in a kind of generic way, please tell!
Bonus points if your solution can also work with other callbacks and not just Channel
aeruhxi
08/20/2018, 12:18 PMlaunch
with runBlocking
, everything works thoughaeruhxi
08/20/2018, 12:18 PMlaunch
with runBlocking
, everything works thoughuli
08/20/2018, 5:20 PMaeruhxi
08/20/2018, 5:42 PMuli
08/20/2018, 9:03 PMaeruhxi
08/21/2018, 6:18 AM