use of il.ac.bgu.cs.bp.bpjs.model.BSyncStatement in project BPjs by bThink-BGU.
the class BProgramSyncSnapshotIO method readBThreadSnapshot.
private BThreadSyncSnapshot readBThreadSnapshot(ScriptableInputStream sis, ScriptableObject scope) throws IOException, ClassNotFoundException {
String name = (String) sis.readObject();
byte[] contBytes = (byte[]) sis.readObject();
final BThreadJsProxy btProxy = new BThreadJsProxy();
final BProgramJsProxy bpProxy = new BProgramJsProxy(bprogram);
StubProvider stubPrv = (StreamObjectStub stub) -> {
if (stub == StreamObjectStub.BP_PROXY) {
return bpProxy;
}
if (stub == StreamObjectStub.BT_PROXY) {
return btProxy;
}
throw new IllegalArgumentException("Unknown stub " + stub);
};
try (ByteArrayInputStream inBytes = new ByteArrayInputStream(contBytes);
BThreadSyncSnapshotInputStream bssis = new BThreadSyncSnapshotInputStream(inBytes, scope, stubPrv)) {
Scriptable btScope = (Scriptable) bssis.readObject();
Function entryPoint = (Function) bssis.readObject();
Function interruptHandler = (Function) bssis.readObject();
BSyncStatement stmt = (BSyncStatement) bssis.readObject();
Object cont = bssis.readObject();
final BThreadSyncSnapshot bThreadSyncSnapshot = new BThreadSyncSnapshot(name, entryPoint, interruptHandler, btScope, cont, stmt);
btProxy.setBThread(bThreadSyncSnapshot);
return bThreadSyncSnapshot;
}
}
Aggregations