Skip to content

Commit

Permalink
Add QCoreApplication event loop to wahjamsrv
Browse files Browse the repository at this point in the history
Use QCoreApplication::processEvents() instead of sleeping in the main
loop.  This allows us to begin using Qt events in the server and it will
eventually be possible to block while waiting for events instead of
spinning.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
  • Loading branch information
stefanha committed Apr 18, 2012
1 parent 9da8e4d commit 608bd06
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ninjam/server/ninjamsrv.cpp
Expand Up @@ -39,6 +39,8 @@
#include <signal.h>
#include <stdarg.h>

#include <QCoreApplication>

#include "../../WDL/jnetlib/jnetlib.h"
#include "../../WDL/jnetlib/httpget.h"
#include "../netmsg.h"
Expand Down Expand Up @@ -646,6 +648,8 @@ bool reloadConfig(int argc, char **argv, bool firstTime)

int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);

if (argc < 2)
{
usage(argv[0]);
Expand Down Expand Up @@ -713,12 +717,7 @@ int main(int argc, char **argv)
{
if (g_server->run())
{
#ifdef _WIN32
Sleep(1);
#else
struct timespec ts={0,1*1000*1000};
nanosleep(&ts,NULL);
#endif
app.processEvents(QEventLoop::AllEvents, 1 /* milliseconds */);

if (g_reloadconfig && strcmp(argv[1],"-"))
{
Expand Down

0 comments on commit 608bd06

Please sign in to comment.