They are serializable right now. You can convert t...
# coroutines
e
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
is there any code snippet that shows that?
e
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
I want to restart or resume a coroutine at the next android app launch if it execution was interrupted due to process death
e
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
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
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
some passed parameters,
id: String
for example
e
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?