use of co.paralleluniverse.io.serialization.ByteArraySerializer in project quasar by puniverse.
the class Actor method migrate.
/**
* Suspends and migrate the actor.
* This method suspends the fiber the actor is running in (and is therefore available only for actors running in fibers),
* so that when the actor is hired, it will continue execution from the point this method was called.
* This method must be called on a fiber.
*/
public void migrate() throws SuspendExecution {
record(1, "Actor", "migrate", "Actor %s is migrating.", this);
verifyOnActorStrand();
migrating = true;
preMigrate();
Fiber.parkAndSerialize(new FiberWriter() {
@Override
public void write(Fiber fiber, ByteArraySerializer ser) {
final byte[] buf = ser.write(Actor.this);
new Fiber<Void>() {
@Override
protected Void run() throws SuspendExecution, InterruptedException {
MigrationService.migrate(getGlobalId(), Actor.this, buf);
postMigrate();
return null;
}
}.start();
}
});
migrating = false;
}
Aggregations