-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- When we add a data into a place, try to fire all the neighboring transitions.
- Loading branch information
Showing
4 changed files
with
40 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export * from "./Net" | ||
export * from "./fireTransitionEntry" | ||
export * from "./createNet" | ||
export * from "./addPlace" | ||
export * from "./addTransition" | ||
export * from "./createNet" | ||
export * from "./findPlaceEntry" | ||
export * from "./findPlaceEntryOrFail" | ||
export * from "./findTransitionEntry" | ||
export * from "./findTransitionEntryOrFail" | ||
export * from "./transitionEntryFire" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
import { reactive } from "@vue/runtime-core" | ||
import { Net } from "../net" | ||
import { reactive, watch } from "@vue/runtime-core" | ||
import { Net, PlaceEntry, transitionEntryFire } from "../net" | ||
|
||
export function react(net: Net): void { | ||
reactive | ||
for (const [nodekey, placeEntry] of net.placeEntries) { | ||
placeEntry.queue = reactive(placeEntry.queue) | ||
reactivelyFireOutputTransitions(placeEntry) | ||
} | ||
|
||
initialAction(net) | ||
} | ||
|
||
async function initialAction(net: Net): Promise<void> { | ||
for (const [nodeKey, transitionEntry] of net.transitionEntries) { | ||
await transitionEntryFire(transitionEntry) | ||
} | ||
} | ||
|
||
// When we add a data into a place, | ||
// try to fire all the neighboring transitions. | ||
|
||
function reactivelyFireOutputTransitions(placeEntry: PlaceEntry): void { | ||
watch( | ||
() => placeEntry.queue, | ||
async () => { | ||
if (placeEntry.queue.length > 0) { | ||
for (const transitionEntry of placeEntry.outputTransitionEntries) { | ||
const result = await transitionEntryFire(transitionEntry) | ||
if (result === "Fired") return | ||
} | ||
} | ||
}, | ||
{ | ||
deep: true, | ||
}, | ||
) | ||
} |