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

dave08

11/01/2017, 10:09 PM
Oh, I thought I'd have to do that, I just wondered if I was missing something or it would be included eventually... Also, how does one make a class out of
actor { }
and still be thread safe, can the class member vars be used or do they have to be contained in the
actor { }
function? And there must be an actor val to keep and return the actor.. one can't call send straight from the class. It would be nice to be able to derive from an actor abstract class...
e

elizarov

11/01/2017, 11:47 PM
If you do an actor class, then keep all its state
private
to it.
d

dave08

11/02/2017, 3:20 AM
Then I'd have to declare
val actor = actor { }
on it and do
ActorClass().actor.send()
, if there would be an abstract class to derive from, it would just be
ActorClass().send()
is there an easy way to do this?
e

elizarov

11/02/2017, 6:42 AM
Go ahead and define yourself an abstract actor class with suspend send method.
d

dave08

11/02/2017, 7:18 AM
I guess I could inherit it from Send channel and delegate the methods to an internal actor to avoid the problem you pointed out to Mr. Lucas a few days ago on his actor compiler... I suppose this won't be added to the core library some time?
2 Views