From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA13654; Sat, 21 Feb 2004 21:49:47 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA16622 for ; Sat, 21 Feb 2004 21:49:46 +0100 (MET) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i1LKnjae017665 for ; Sat, 21 Feb 2004 21:49:46 +0100 Received: from liafa1.liafa.jussieu.fr (liafa1.liafa.jussieu.fr [132.227.93.1]) by shiva.jussieu.fr (8.12.10/jtpda-5.4) with ESMTP id i1LKnjG3090806 for ; Sat, 21 Feb 2004 21:49:45 +0100 (CET) X-Ids: 166 Received: from liafa0.liafa.jussieu.fr (liafa0.liafa.jussieu.fr [132.227.81.1]) by liafa1.liafa.jussieu.fr (8.12.2/jtpda-5.3.2) with ESMTP id i1LKne3l009760 for ; Sat, 21 Feb 2004 21:49:40 +0100 (CET) Received: from liafa0.liafa.jussieu.fr (localhost [127.0.0.1]) by liafa0.liafa.jussieu.fr (8.12.8/jtpda-5.4) with ESMTP id i1LKneZ7019181 for ; Sat, 21 Feb 2004 21:49:40 +0100 Received: (from durak@localhost) by liafa0.liafa.jussieu.fr (8.12.8/8.12.8/Submit) id i1LKneGQ019179 for caml-list@inria.fr; Sat, 21 Feb 2004 21:49:40 +0100 Date: Sat, 21 Feb 2004 21:49:40 +0100 From: Berke Durak To: caml-list@inria.fr Subject: [Caml-list] Threads, graphics and timeouts ; functor for multiple windows Message-ID: <20040221204940.GA19204@liafa.jussieu.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4i X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Miltered: at shiva.jussieu.fr with ID 4037C469.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Antivirus: scanned by sophie at shiva.jussieu.fr X-Loop: caml-list@inria.fr X-Spam: no; 0.00; berke:01 durak:01 durak:01 threads:01 timeouts:01 functor:01 clone:01 threads:01 keypress:01 keypress:01 ticker:99 aborting:01 val:01 struct:01 struct:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello everyone, Last year I was writing some Tetris® clone in Ocaml using the graphics library... I had to patch the graphics library to include a Timeout event, because it wouldn't work with threads. I've tried again yesterday with 3.07. Basically, whatever I do I get "interrupted system call select" errors. Today, the graphics library still doesn't work with threads. I have tried both bytecode scheduling and pthreads. I would like to make programs that work as follows : while true do let t = compute_timeout () in match wait_for_keypress_or_timeout t with | Timeout -> do_something | Keypress k -> do_something else done I've tried with threads, using a "ticker" thread that communicated with the main thread via events. It didn't work because there is no timeout event ; and even if the timer thread sends a signal every second, I get the "interrupted system call select" error (particularly when the system load increases). I then used a Unix pipe with timed_read. Same problem. Is there a way to write a (graphical) Tetris with Ocaml with the Graphics library ? I'd like to make a few wild suggestions : - In the Event module : - Add a timeout event - Provide a mechanism for aborting events - Or add a timed wait function - In the Graphics library : - Fix the issues with threads - Include a timeout event (see my patch at http://www.liafa.jussieu.fr/~durak/) Another suggestion to provide for multiple windows in graphics : module type WINDOW_ID = sig val id : int end module Builder(W:WINDOW_ID) : GRAPHICS_MODULE Ie to have multiple windows (say two) you'd just have to make : let G1 = Graphics.Builder(struct let id = 1 end) in let G2 = Graphics.Builder(struct let id = 2 end) in G1.open_window " 100x30"; G2.open_window " 100x50"; G1.moveto 0 0; G1.draw_string "this is window 1"; G2.moveto 0 0; G2.draw_string "this is window 1" -- Berke Durak ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners