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

Spec.Coroutines History

Hide minor edits - Show changes to output

2010-01-14 20:00 by benjk - changed module name to uppercase as per system module convention
Changed lines 1-2 from:
[@DEFINITION MODULE Coroutines;
to:
[@DEFINITION MODULE COROUTINES;
Changed line 21 from:
EDN Coroutines.@]
to:
EDN COROUTINES.@]
2010-01-13 10:44 by benjk - new file by benjk
Added lines 1-21:
[@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.@]