On Nov 23, 2007 3:52 PM, Tor Lillqvist <[EMAIL PROTECTED]> wrote:
> > int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
> LPSTR
> > lpCmdLine, int nCmdShow)
>
> Please don't unnecessarily use WinMain(), it only confuses matters,
> and can make people think it is significant for the problem. (It
> isn't)
>
> > {
> > GMainLoop *MainLoop = NULL;
> >
> > MainLoop = g_main_loop_new(NULL, TRUE);
> > g_main_loop_run(MainLoop);
> > }
>
> > Even this minimalist program eats 100% CPU.
>
> Well, you haven't added any event source to the main loop. What do you
> expect the code to do? Sure, on Windows GLib gets stuck in a loop and
> on Linux it apparently just hangs forever instead, and it probably
> could be argued that it should just hang forever on Windows, too, but
> from a functionality perspective, what is the difference? In both
> cases, the code will forever be doing nothing.
Totally agree :-)
I usually add a g_usleep() idle callback which also provide a heartbeat info
for my application. This way, at least the main loop is doing something :-)
The g_usleep() could be 5 sec, 10 sec ... don't matter. If it's long
enough,
it won't hurt any performance.
KC
>
>
> On Linux it will call poll(NULL, 0, -1) which hangs forever. I can't
> see this behaviour documented in the poll(2) manpage, though. The
> g_poll() function used in GLib on Windows to "emulate" poll() just
> returns immediately if there is nothing to wait for. I guess it would
> be easy to change that to make it hang forever instead. I can't say I
> am convinced that would be more correct, though.
>
> --tml
> _______________________________________________
> gtk-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list