https://kotlinlang.org logo
Title
e

elizarov

04/13/2017, 5:26 PM
They are serializable right now. You can convert them to byte array with your favorite serialization framework. You just have to provide serializable context and make sure that all the locals are serializable. Then you can parcel the resulting byte array. I'm curios as to what is your use-case, though?
a

adambl4

04/13/2017, 5:33 PM
is there any code snippet that shows that?
e

elizarov

04/13/2017, 5:38 PM
I can write one for you. However, there many meanings as to what a "serializable coroutine", so I need to understand your use-case first. What are you trying to accomplish?
Also, what are your platform constraints? Can you use Java serialization? Kryo?
a

adambl4

04/13/2017, 5:42 PM
I want to restart or resume a coroutine at the next android app launch if it execution was interrupted due to process death
e

elizarov

04/13/2017, 6:01 PM
So, you have to solve restoring of all its context first. How do you active that? What does your coroutine do? And what does "interrupted by process death" means?
a

adambl4

04/13/2017, 6:28 PM
Mostly my coroutines involves network communication, so their execution may take a long time. The process may be easily killed by the system if user switched the app.
e

elizarov

04/13/2017, 7:07 PM
Why you cannot just restart your network communication coroutines when you app starts up? What kind of coroutine state you want preserve by serializing them?
a

adambl4

04/13/2017, 7:16 PM
some passed parameters,
id: String
for example
e

elizarov

04/13/2017, 7:54 PM
And if coroutine was suspended waiting for some network answer what shall happen what its restored? Retry operation or error? More importantly, how and where does coroutine communicates result of its work and how this answer will get to the poper place when we deserialize and restart it?