Package com.offbynull.coroutines.user
Class CoroutineWriter
java.lang.Object
com.offbynull.coroutines.user.CoroutineWriter
Writes out (serializes) the current state of a
CoroutineRunner
object.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Coroutine serializer.static final class
Default implementation ofCoroutineWriter.CoroutineSerializer
(uses Java's built-in serialization mechanism). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
private final CoroutineWriter.CoroutineSerializer
private final Map
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct aCoroutineWriter
object.CoroutineWriter
(CoroutineWriter.CoroutineSerializer serializer, SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineWriter
object.CoroutineWriter
(SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineWriter
.CoroutineWriter
(SerializedState.FrameUpdatePoint[] frameUpdatePoints) Constructs aCoroutineWriter
.CoroutineWriter
(SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineWriter
. -
Method Summary
Modifier and TypeMethodDescriptionprivate int[]
clearContinuationReferences
(Object[] objects, Continuation cn) deconstruct
(CoroutineRunner runner) Deconstructs aCoroutineRunner
object to a serializable state.byte[]
write
(CoroutineRunner runner) Serializes aCoroutineRunner
object as a byte array.
-
Field Details
-
serializer
-
updatersMap
-
interceptersMap
-
-
Constructor Details
-
CoroutineWriter
public CoroutineWriter()Construct aCoroutineWriter
object. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), new FrameUpdatePoint[0], new FrameInterceptPoint[0])
. -
CoroutineWriter
Constructs aCoroutineWriter
. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), frameUpdatePoints, new FrameInterceptPoint[0])
.- Parameters:
frameUpdatePoints
- frame update points- Throws:
IllegalArgumentException
- ifframeUpdatePoints
contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint)NullPointerException
- if any argument isnull
-
CoroutineWriter
Constructs aCoroutineWriter
. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), new FrameUpdatePoint[0], frameInterceptPoints)
.- Parameters:
frameInterceptPoints
- frame intercept points- Throws:
IllegalArgumentException
- ifframeInterceptPoints
contains more than one entry for the same identifier (className/methodId/continuationPoint)NullPointerException
- if any argument isnull
-
CoroutineWriter
public CoroutineWriter(SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineWriter
. Equivalent to callingnew CoroutineWriter(new DefaultCoroutineSerializer(), frameUpdatePoints, frameInterceptPoints)
.- Parameters:
frameUpdatePoints
- frame update pointsframeInterceptPoints
- frame intercept points- Throws:
IllegalArgumentException
- ifframeUpdatePoints
contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or ifframeInterceptPoints
contains more than one entry for the same identifier (className/methodId/continuationPoint)NullPointerException
- if any argument isnull
-
CoroutineWriter
public CoroutineWriter(CoroutineWriter.CoroutineSerializer serializer, SerializedState.FrameUpdatePoint[] frameUpdatePoints, SerializedState.FrameInterceptPoint[] frameInterceptPoints) Constructs aCoroutineWriter
object.- Parameters:
serializer
- serializer to write out the coroutine stateframeUpdatePoints
- frame update pointsframeInterceptPoints
- frame intercept points- Throws:
NullPointerException
- if any argument isnull
or containsnull
IllegalArgumentException
- ifframeUpdatePoints
contains more than one entry for the same identifier (className/oldMethodId/newMethodId/continuationPoint), or ifframeInterceptPoints
contains more than one entry for the same identifier (className/methodId/continuationPoint)
-
-
Method Details
-
write
Serializes aCoroutineRunner
object as a byte array.- Parameters:
runner
- coroutine runner to serialize- Returns:
runner
serialized to byte array- Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- if failed to serialize
-
deconstruct
Deconstructs aCoroutineRunner
object to a serializable state.- Parameters:
runner
- coroutine runner to deconstruct- Returns:
- deconstructed representation of
CoroutineRunner
- Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- if failed to deconstruct
-
clearContinuationReferences
-