English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Why 'Graphics.wait_next_event' doesn't reply anymore ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-11-12 (21:18)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Why 'Graphics.wait_next_event' doesn't reply anymore ?
Hi Fabrice,

Zitat von Fabrice Marchant <fabrice.marchant@orange.fr>:
>   In fact the true application where the problem originally raised is :
> http://fabrice.marchant.free.fr/funLife/

I only have looked some minutes into the code.
fast browsed ;-)

Both threads use the Graphics-module (via View-module).
Possibly the problem is, that the access
is not protected: use Mutexes, when calling the View.<function>,
so that each Thread only has access to the View-functions
(and the Graphics module's functions), when the other thread
is ready with it's work. Otherwise possibly things become confused.

So, wrap each of the View.<function> calls with
calls to Mutex.lock and Mutex.unlock.

Possibly this is your main problem!


P.S.: The Mutex must be in the environment of both threads,
      so must be defined at the toplevel of the autoPlay.ml,
      which means unit-global, as "running" also is.