@metamask/ocap-kernel
Version:
OCap kernel core components
64 lines • 2.67 kB
text/typescript
import type { VatOneResolution } from "@agoric/swingset-liveslots";
import type { CapData } from "@endo/marshal";
import type { KernelStore } from "./store/index.cjs";
import type { CrankResults, KRef, Message, RunQueueItem, VatId } from "./types.cjs";
/**
* The kernel's run queue.
*
* This class manages the kernel's run queue, which is a queue of items that
* need to be processed.
*/
export declare class KernelQueue {
#private;
/** Message results that the kernel itself has subscribed to */
readonly subscriptions: Map<KRef, (value: CapData<KRef>) => void>;
constructor(kernelStore: KernelStore, terminateVat: (vatId: VatId, reason?: CapData<KRef>) => Promise<void>);
/**
* The kernel's run loop: take an item off the run queue, deliver it,
* repeat. Note that this loops forever: the returned promise never resolves.
*
* @param deliver - A function that delivers an item to the kernel.
*/
run(deliver: (item: RunQueueItem) => Promise<CrankResults | undefined>): Promise<void>;
/**
* Queue a message to be delivered from the kernel to an object in a vat.
*
* @param target - The object to which the message is directed.
* @param method - The method to be invoked.
* @param args - Message arguments.
*
* @returns a promise for the (CapData encoded) result of the message invocation.
*/
enqueueMessage(target: KRef, method: string, args: unknown[]): Promise<CapData<KRef>>;
/**
* Enqueue a send message to be delivered to a vat.
*
* @param target - The object to which the message is directed.
* @param message - The message to be delivered.
*/
enqueueSend(target: KRef, message: Message): void;
/**
* Enqueue for delivery a notification to a vat about the resolution of a
* promise.
*
* @param vatId - The vat that will be notified.
* @param kpid - The promise of interest.
*/
enqueueNotify(vatId: VatId, kpid: KRef): void;
/**
* Wait for the current crank to complete.
* This method can be called by external operations to ensure they don't interfere
* with ongoing kernel operations.
*
* @returns A promise that resolves when the current crank is finished.
*/
waitForCrank(): Promise<void>;
/**
* Process a set of promise resolutions coming from a vat.
*
* @param vatId - The vat doing the resolving, if there is one.
* @param resolutions - One or more resolutions, to be processed as a group.
*/
resolvePromises(vatId: VatId | undefined, resolutions: VatOneResolution[]): void;
}
//# sourceMappingURL=KernelQueue.d.cts.map