Commit e599e52c authored by Linshizhi's avatar Linshizhi

Add exception to Channel.

parent f648fb83
import { assert, NEED_TO_IMPLEMENT } from './utils.js';
class ChnlStepConflictError extends Error {
constructor() {
super("Channel Step error");
}
}
class CpySchedule {
first = { pos : 0, size: 0 };
second = { pos : 0, size: 0 };
......@@ -406,7 +413,7 @@ export class Channel {
}
if (this.#writePhase != WRITE_PHASE.NO_STEP_WRITE)
throw new Error("Unable to call multiple writeStep1()");
throw new ChnlStepConflictError();
this.#writePhase = WRITE_PHASE.WAIT_CALLER_WRITE;
let schedule = this.#cpySchedule(size);
......@@ -437,7 +444,7 @@ export class Channel {
writeStep2() {
if (this.#writePhase != WRITE_PHASE.WAIT_CALLER_WRITE)
throw new Error("Have to call writeStep1() first")
throw new ChnlStepConflictError();
this.#writePointerUpdate(this.#writePhaseEndPos);
this.#writePhase = WRITE_PHASE.NO_STEP_WRITE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment