Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Simple augmentation of reader allows MS Graphics...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-02-14 (22:31)
From: David McClain <dmcclain@a...>
Subject: Simple augmentation of reader allows MS Graphics...
It is well known that Win32 console mode I/O blocks the event loop for
graphics threads. A simple external augmentation of read() allows new OCAML
toplevels to perform Window Graphics, without recompiling or altering the
runtime system.

Microsoft has graciously named their I/O primitive "_read( )" so that we can
create our own "read( )" routine to intercept uses of it at link time,
substituting our own version that in turn calls the C runtime primitive
"_read( )" when it is more appropriate -- such as from another thread. This
allows up to pump message queues in the main thread, and to start up other
graphics threads without the problems normally encountered by a blocking
"read( )".

You can get some sample code at

This code includes the augmented "read( )" routine, a separate console
reader thread, and a separate graphics thread that puts up a simple window
with some imagery. This code can be compiled and used ahead of the C runtime
libraries in the link command of "ocamlmktop" to create new toplevels that
enable Win32 graphics.

David McClain
Sr. Scientist
Raytheon Missile Systems Co.
Tucson, AZ