[Ruby] Tk.mainloop ест 99% cpu
Ihar Viarheichyk
i.viarheichyk at sam-solutions.net
Thu Feb 6 16:41:06 MSK 2003
On Thu, Feb 06, 2003 at 02:16:45PM +0300, Vladimir V. Zdorovenco wrote:
> >
> > Нет. Это независимые вещи. Tk - биндинги Tk-шных виджетов для Ruby, как
> > в Perl/Tk. TclTk - это подключение интерпретатора Tcl/Tk, которому можно
> > скармливать тиклевые команды на исполнение, как Tkiner в Python.
>
> Да да, я несовсем корретно выразился, но суть в принцыпе одна и таже, ее
> выразить можно по разному. Вы лучше с mainloop помогите разобратся.
>
> Вот что я нашел по этому поводу в ихнем мыллисте:
>
> 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?
>
Можно ещё поизвращаться по-разному. Например, так - работает и не жрет
ресурсы:
require 'tk'
root = TkRoot.new
TkButton.new(root) {
text "hello"
command proc {puts "hello workd"}
pack
}
root.bind("Destroy") {exit}
TkCore::INTERP._invoke('vwait', 'fake_variable')
--
Igor Vergeichik
ICQ 47298730
More information about the Ruby
mailing list