Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Coroutines

DEFINITION MODULE COROUTINES;

(* Coroutine library *)

FROM SYSTEM IMPORT ADDRESS;

TYPE
    Coroutine = OPAQUE;

    CoroutineProc = PROCEDURE ( ADDRESS );

PROCEDURE New( p : CoroutineProc; stackSize : LONGCARD ) : Coroutine;
  (* Returns a new coroutine with stack size stackSize, associated with procedure p. *)

PROCEDURE Yield( coroutine : Coroutine; sharedData: ADDRESS );
  (* Transfers control to coroutine, passing an address for shared data in sharedData. *)

PROCEDURE Dispose( coroutine : Coroutine ) : Coroutine;
  (* Disposes of coroutine and returns NIL. *)

EDN COROUTINES.