/*高速缓冲保存线程*/ void CacheProc(DWORD interval) { for (;;) { KSleep(interval); SaveCache(); } }
int KibaMain(int argc, char** argv) { TestServer srv; if (!srv.Init("TestServer.xml")) return -1; SLogService::GetSingleton().GetLogger()->SetConsoleShow(true); SLogService::GetSingleton().GetLogger()->Info("%s is running ...", srv.GetName().c_str()); while (srv.IsRunning()) { //SLogService::GetSingleton().GetLogger()->Info("Time tick"); srv.Tick(); CheckInput(); if (!g_running) { SLogService::GetSingleton().GetLogger()->Info("Stop"); srv.Stop(); break; } if (g_reloadconfig) { SLogService::GetSingleton().GetLogger()->Info("ReloadConfig"); srv.ReloadConfig(); g_reloadconfig = false; } if (g_showconnnum) { srv.ShowConnNum(); g_showconnnum = false; } KSleep(100); } srv.Final(); return 0; }
int main(int argc, char *argv[]) { TM nowtime; if (GDIinit() != NO_ERROR) return NO_ERROR; for(;;) { float i, tmphor; TMCurTime(&nowtime); //背景 GDIFillRect(GDIwidth - CLOCK_WID, 0, CLOCK_WID, CLOCK_WID, 0); //表盘 GDIcircle(CLOCK_X, CLOCK_Y, CLOCK_R, 0xFFFFFF); //刻度 for (i = 0.f; i < 12.f * PI / 6.f; i += PI / 6.f) { float cosa, sina; cosa = cos(i); sina = sin(i); GDIDrawLine(CLOCK_X + (long)(CLOCK_R * cosa), CLOCK_Y + (long)(CLOCK_R * sina), CLOCK_X + (long)((CLOCK_R - 3) * cosa), CLOCK_Y + (long)((CLOCK_R - 3) * sina), 0xFFFFFF); } GDIDrawStr(CLOCK_X + CLOCK_R - 8, CLOCK_Y - 6, "3", 0xFFFFFF); GDIDrawStr(CLOCK_X - 2, CLOCK_Y + CLOCK_R - 15, "6", 0xFFFFFF); GDIDrawStr(CLOCK_X - CLOCK_R + 5, CLOCK_Y - 6, "9", 0xFFFFFF); GDIDrawStr(CLOCK_X - 5, CLOCK_Y - CLOCK_R + 3, "12", 0xFFFFFF); //指针 tmphor = (nowtime.hor + (float)nowtime.min / 60.f) * PI / 6.f; GDIDrawLine(CLOCK_X, CLOCK_Y, CLOCK_X + 15.f * sin(tmphor), CLOCK_Y - 15.f * cos(tmphor), 0xFFFFFF); GDIDrawLine(CLOCK_X, CLOCK_Y, CLOCK_X + 20.f * sin(nowtime.min * PI / 30.f), CLOCK_Y - 20.f * cos(nowtime.min * PI / 30.f), 0xFFFFFF); GDIDrawLine(CLOCK_X, CLOCK_Y, CLOCK_X + 25.f * sin(nowtime.sec * PI / 30.f), CLOCK_Y - 25.f * cos(nowtime.sec * PI / 30.f), 0xFFFFFF); KSleep(100); } GDIrelease(); return NO_ERROR; }