[gnet] Question about gnet and g_main_loop_run

I am using gnet in a windows application. I create a thread which runs g_main_loop_run(); In my main application thread i create the server by calling gnet_server_new().

The problem is that nothing works if i create the server after g_main_loop_run has been executed. It is important that i can create a server at any time, not only before g_main_loop()

I have found a way to overcome this. If instead of calling g_main_loop_run() in my second thread
i call

g_main_context_iteration (context, false); //See if any events to poll

in a loop then everything works fine.
The problem in this solution is active waiting. The cpu usage reaches 99%

I wonder if anyone could help me with this. I would like to be able
to create a new server anytime but still without the cpu usage cost.

Thank you in advance.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]