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

camdenorrb

02/17/2019, 3:51 PM
How do I use the Main dispatcher if my platform isn't Android?
e

elizarov

02/17/2019, 3:59 PM
What's your UI framework?
c

camdenorrb

02/17/2019, 3:59 PM
I'm not using a UI
e

elizarov

02/17/2019, 3:59 PM
Then you don't have Main dispatcher.
(nor need one)
c

camdenorrb

02/17/2019, 3:59 PM
:C
Concurrent modification issues tho
e

elizarov

02/17/2019, 4:00 PM
Don't share mutable state. No issues
(don't make mistake UI frameworks do)
c

camdenorrb

02/17/2019, 4:00 PM
I'm just adding something to my eventbus
e

elizarov

02/17/2019, 4:01 PM
Isn't your eventbus thread-safe?
c

camdenorrb

02/17/2019, 4:01 PM
Ummmm, not currently lol
e

elizarov

02/17/2019, 4:01 PM
That's a bad event bus
c

camdenorrb

02/17/2019, 4:01 PM
;-;
e

elizarov

02/17/2019, 4:02 PM
c

camdenorrb

02/17/2019, 4:02 PM
Thank you :3
Unfortunately after giving it a read, I don't think it helped me very much idea wise. The only thing I got that seems useful is Mutex for the situation I have run in. Anything else I can read @elizarov?
e

elizarov

02/17/2019, 4:43 PM
It really depends on what you are trying to achieve
c

camdenorrb

02/17/2019, 4:43 PM
I want to add multithreading/coroutine support to my eventbus
Which at the moment, just seems to be an issue with concurrently adding a value to the list
e

elizarov

02/17/2019, 4:44 PM
You might want to learn more about concurrency, first. "Java Concurrency in Practice" is a good book I can recommend.
c

camdenorrb

02/17/2019, 4:45 PM
Alright
e

elizarov

02/17/2019, 4:45 PM
As for coroutines, the easiest thing (that would not require any sharing of mutable state) is to represent your eventbus as an actor, that is confine all its operations to a single coroutine.
c

camdenorrb

02/17/2019, 4:46 PM
Ooo, alright. I'll read up on actors :3
d

dewildte

02/18/2019, 6:03 PM
@elizarov Do you suggest using actor coroutines as the event bus for a multiplatform application?
6 Views