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;
}
return 126;
}
+#ifndef WIN32 //XXX
signal(SIGALRM, &sigalrm_);
+#endif
try
{
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
if(poller_)
poller_->poll(0);
tick();
+#ifdef WIN32
+ Sleep(0);
+#else
sched_yield();
+#endif
}
else
{
poller_->poll(-1);
else
{
+#ifdef WIN32
+ Sleep(1);
+#else
timespec ts={1000,0};
nanosleep(&ts, 0);
+#endif
}
if(tick_mode_!=NONE)
tick();
void Application::set_tick_mode(TickMode t)
{
tick_mode_=t;
+#ifndef WIN32 //XXX
pthread_kill(main_tid, SIGALRM);
+#endif
}
/**
{
done=true;
exit_code=c;
+#ifndef WIN32 //XXX
pthread_kill(main_tid, SIGALRM);
+#endif
}
void Application::sighandler_(int s)