X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fapplication.cpp;h=a9aa88ea55bdee578d81238d614120a962be2173;hp=765b0670d3ecee5ccaad9228b02306769022e0d7;hb=727f8ce40806cc2f7c295260f3c9aa156c815c70;hpb=1013e3c216cdf8e0ecc0f3b1e8314989b5333818 diff --git a/source/application.cpp b/source/application.cpp index 765b067..a9aa88e 100644 --- a/source/application.cpp +++ b/source/application.cpp @@ -19,7 +19,9 @@ Poller::Slot &Application::add_pollable(Pollable *obj, short events) Poller::Slot &slot=poller_->add_pollable(obj, events); // Interrupt a possible poll in progress - pthread_kill(main_tid, SIGALRM); +#ifndef WIN32 //XXX + pthread_kill(main_tid, SIGALRM); +#endif return slot; } @@ -62,7 +64,9 @@ int Application::run(int argc, char **argv) return 126; } +#ifndef WIN32 //XXX signal(SIGALRM, &sigalrm_); +#endif try { @@ -91,6 +95,17 @@ void Application::usage(const char *, bool) cerr<<"The programmer was lazy and didn't write a usage() function for this application.\n"; } +Application::Application(): + exit_code(0), + tick_mode_(IDLE), + poller_(0), + ev_mgr_(0) +#ifndef WIN32 + //XXX Figure out how to get the current thread on win32 + ,main_tid(pthread_self()) +#endif +{ } + /** Default main loop. Calls tick() periodically if do_ticks is true, otherwise just sleeps. A custom main loop should monitor the done member variable and @@ -106,7 +121,11 @@ int Application::main() if(poller_) poller_->poll(0); tick(); +#ifdef WIN32 + Sleep(0); +#else sched_yield(); +#endif } else { @@ -114,8 +133,12 @@ int Application::main() poller_->poll(-1); else { +#ifdef WIN32 + Sleep(1); +#else timespec ts={1000,0}; nanosleep(&ts, 0); +#endif } if(tick_mode_!=NONE) tick(); @@ -136,7 +159,9 @@ void Application::catch_signal(int s) void Application::set_tick_mode(TickMode t) { tick_mode_=t; +#ifndef WIN32 //XXX pthread_kill(main_tid, SIGALRM); +#endif } /** @@ -146,7 +171,9 @@ void Application::exit(int c) { done=true; exit_code=c; +#ifndef WIN32 //XXX pthread_kill(main_tid, SIGALRM); +#endif } void Application::sighandler_(int s)