From: nagai@... Date: 2002-12-25T15:58:19+09:00 Subject: Ruby/Tk problem (Re: ANN: ruby 1.6.8) Hi, From: "Kero van Gelder" Subject: Re: ANN: ruby 1.6.8 Date: Wed, 25 Dec 2002 10:01:13 +0900 Message-ID: kero> Ruby/Tk uses 100% CPU (as reported for a preview) kero> worse, when using Tk 8.4, I don't see any window (works with Tk 8.3) I know. But I don't have enough time and any idea to fix this problem. Of course, if use old Tk.mainloop, Ruby/Tk doesn't use 100% CPU, though some Ruby/Tk script will hang up. For example, some cases of following situation makes Ruby/Tk hanging up. -------------------------------------------------- First, Tk calls Ruby (e.g. event callback). Then the event loop *waits* for Ruby operation. The called Ruby calls Tk (e.g. treat Tk widget) and waits for finishing Tk operation. But to finish the Tk operation, the event loop must be running. -------------------------------------------------- Current Tk.mainloop starts a watch-dog thread. If the event loop is sleeping, the watch-dog thread starts new event loop. The old Tk.mainloop uses a timer for thread switching. Even if no Tk operations which waiting for proceeding, Ruby/Tk waits the time for thread switching. The current Tk.mainloop uses Tcl_DoOneEvent function with TCL_DONT_WAIT. So, if no event is waiting, Ruby can do thread switching quickly. But if no other thread is running, the cost of Tcl_DoOneEvent loop may be unreasonable. Do you have any good idea for the problem? -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)