Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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

    http://www.azstarnet.com/~dmcclain/graphics.cpp

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
http://www.azstarnet.com/~dmcclain/homepage.htm