import { mo } from '../../src/index.ts'; import type { SharedStruct, Int32, Mutex } from '../../src/index.ts'; type Position = SharedStruct<{ x: Int32; y: Int32 }>; export const updatePosition = mo( import.meta, async (mu: Mutex, pos: Position, dx: number, dy: number, steps: number): Promise => { for (let i = 0; i < steps; i++) { using guard = await mu.lock(); const current = pos.load(); pos.store({ x: current.x + dx, y: current.y + dy }); } }, );