Reputation: 172
I'm searching for a network library for mobile game client side networking.
I'm currently using cocos2d-x with Lua for client side programming.
I'm consider use libuv or luv (a Lua binding for libuv) in my client side networking library (TCP).
Running libuv loop in UV_RUN_ONCE or UV_RUN_NOWAIT mode each frame in game main loop (main thread). When libuv received networking data, it calls my callback Lua functions in game main thread (where the Lua VM runs), and my Lua code decrypt and decode and process the message.
My question is:
will libuv make my game mainloop slow and drop my fps when networking traffic goes up (of course when within a reasonable message size and amount)?
need I put libuv loop in another thread and wrap the callback delay called my Lua functions in main thread?
Upvotes: 1
Views: 752
Reputation: 1392
Yes you can with UV_RUN_NOWAIT, it will run any every queued event in the event loop with it and if there are none, it will just return.
UV_RUN_ONCE for example will bock until there is at least one event in the queue.
Upvotes: 1