mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-24 00:54:18 +08:00
restore the system interval timer for the server under runmode procs
This commit is contained in:
+3
-34
@@ -911,40 +911,9 @@ static inline MSGQUEUE* getMsgQueueIfMainWindowInThisThread (PMAINWIN pMainWin)
|
||||
|
||||
#endif /* defined _MGHAVE_VIRTUAL_WINDOW */
|
||||
|
||||
#if 0 /* deprecated code */
|
||||
/* since 5.0.0, we always use QS_DESKTIMER for desktop timer */
|
||||
/* since 5.0.0, we no longer use the timer thread */
|
||||
static inline void AlertDesktopTimerEvent (void)
|
||||
{
|
||||
if (__mg_dsk_msg_queue) {
|
||||
__mg_dsk_msg_queue->expired_timer_mask = 1;
|
||||
POST_MSGQ (__mg_dsk_msg_queue);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void AlertDesktopTimerEvent (void)
|
||||
{
|
||||
__mg_dsk_msg_queue->dwState |= QS_DESKTIMER;
|
||||
#ifdef _MGHAVE_VIRTUAL_WINDOW
|
||||
if (getMsgQueueForThisThread() != __mg_dsk_msg_queue)
|
||||
POST_MSGQ (__mg_dsk_msg_queue);
|
||||
#endif /* defined _MGHAVE_VIRTUAL_WINDOW */
|
||||
}
|
||||
|
||||
static inline void setMsgQueueTimerFlag (PMSGQUEUE pMsgQueue, int slot)
|
||||
{
|
||||
pMsgQueue->expired_timer_mask |= (0x01UL << slot);
|
||||
POST_MSGQ (pMsgQueue);
|
||||
}
|
||||
|
||||
static inline void removeMsgQueueTimerFlag (PMSGQUEUE pMsgQueue, int slot)
|
||||
{
|
||||
pMsgQueue->expired_timer_mask &= ~(0x01UL << slot);
|
||||
}
|
||||
#endif /* deprecated code */
|
||||
|
||||
BOOL mg_InitTimer (BOOL use_sys_timer);
|
||||
void mg_TerminateTimer (BOOL use_sys_timer);
|
||||
/* Since 5.0.14, remove arg use_sys_timer */
|
||||
BOOL mg_InitTimer (void);
|
||||
void mg_TerminateTimer (void);
|
||||
|
||||
/*window element renderer manager interface*/
|
||||
extern WINDOW_ELEMENT_RENDERER * __mg_def_renderer;
|
||||
|
||||
+2
-2
@@ -577,7 +577,7 @@ int GUIAPI InitGUI (int args, const char *agr[])
|
||||
|
||||
/* init timer for tick counter */
|
||||
step++;
|
||||
if (!mg_InitTimer (FALSE)) {
|
||||
if (!mg_InitTimer()) {
|
||||
_ERR_PRINTF ("KERNEL>InitGUI: failed to start time counter\n");
|
||||
goto failure;
|
||||
}
|
||||
@@ -602,7 +602,7 @@ failure1:
|
||||
|
||||
void GUIAPI TerminateGUI (int not_used)
|
||||
{
|
||||
mg_TerminateTimer (FALSE);
|
||||
mg_TerminateTimer ();
|
||||
|
||||
mg_FreeMsgQueueForThisThread (TRUE);
|
||||
|
||||
|
||||
+67
-10
@@ -117,26 +117,83 @@ DWORD __mg_update_tick_count (MSGQUEUE* msg_queue)
|
||||
return ticks;
|
||||
}
|
||||
|
||||
BOOL mg_InitTimer (BOOL use_sys_timer)
|
||||
#if defined(_MGRM_PROCESSES)
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
static struct sigaction old_alarm_handler;
|
||||
static struct itimerval old_timer;
|
||||
|
||||
static void timer_handler(int sig)
|
||||
{
|
||||
__mg_tick_counter = 0;
|
||||
(void)sig;
|
||||
__mg_update_tick_count(NULL);
|
||||
}
|
||||
|
||||
__mg_os_start_time();
|
||||
static BOOL install_system_timer (void)
|
||||
{
|
||||
struct itimerval timerv;
|
||||
struct sigaction siga;
|
||||
|
||||
if (use_sys_timer) {
|
||||
// Since 5.0.14, do nothing.
|
||||
// install_system_timer ();
|
||||
sigaction (SIGALRM, NULL, &old_alarm_handler);
|
||||
|
||||
siga = old_alarm_handler;
|
||||
siga.sa_handler = timer_handler;
|
||||
siga.sa_flags = 0;
|
||||
sigaction (SIGALRM, &siga, NULL);
|
||||
|
||||
timerv.it_interval.tv_sec = 0;
|
||||
timerv.it_interval.tv_usec = 10000; /* 10 ms */
|
||||
timerv.it_value = timerv.it_interval;
|
||||
|
||||
if (setitimer (ITIMER_REAL, &timerv, &old_timer) == -1) {
|
||||
TIMER_ERR_SYS ("setitimer call failed!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mg_TerminateTimer (BOOL use_sys_timer)
|
||||
static BOOL unintall_system_timer (void)
|
||||
{
|
||||
if (use_sys_timer) {
|
||||
// Since 5.0.14, do nothing.
|
||||
// unintall_system_timer ();
|
||||
if (setitimer (ITIMER_REAL, &old_timer, 0) == -1) {
|
||||
TIMER_ERR_SYS ("setitimer call failed!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (sigaction (SIGALRM, &old_alarm_handler, NULL) == -1) {
|
||||
TIMER_ERR_SYS ("sigaction call failed!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* defined(_MGRM_PROCESSES) */
|
||||
|
||||
BOOL mg_InitTimer ()
|
||||
{
|
||||
__mg_tick_counter = 0;
|
||||
|
||||
__mg_os_start_time();
|
||||
|
||||
#if defined(_MGRM_PROCESSES)
|
||||
if (mgIsServer) {
|
||||
install_system_timer ();
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mg_TerminateTimer (void)
|
||||
{
|
||||
#if defined(_MGRM_PROCESSES)
|
||||
if (mgIsServer) {
|
||||
unintall_system_timer ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************* Functions run in message thread *******************/
|
||||
|
||||
+2
-24
@@ -84,20 +84,6 @@ extern DWORD __mg_tick_counter;
|
||||
|
||||
ON_NEW_DEL_CLIENT OnNewDelClient = NULL;
|
||||
|
||||
#if 0
|
||||
/* Since 5.0.0, use RegisterEventHookFunc to implement SetServerEventHook */
|
||||
static SRVEVTHOOK srv_evt_hook = NULL;
|
||||
|
||||
SRVEVTHOOK GUIAPI SetServerEventHook (SRVEVTHOOK SrvEvtHook)
|
||||
{
|
||||
SRVEVTHOOK old_hook = srv_evt_hook;
|
||||
|
||||
srv_evt_hook = SrvEvtHook;
|
||||
|
||||
return old_hook;
|
||||
}
|
||||
#endif /* deprecated code; moved to window.c */
|
||||
|
||||
static void ParseEvent (PMSGQUEUE msg_que, int event)
|
||||
{
|
||||
LWEVENT lwe;
|
||||
@@ -323,7 +309,7 @@ BOOL GUIAPI ServerStartup (int nr_globals,
|
||||
__mg_dsk_msg_queue->maxfd = listenfd;
|
||||
maxi = -1;
|
||||
|
||||
mg_InitTimer (TRUE);
|
||||
mg_InitTimer ();
|
||||
|
||||
__mg_start_server_desktop ();
|
||||
|
||||
@@ -347,7 +333,7 @@ void server_ServerCleanup (void)
|
||||
{
|
||||
__mg_cleanup_layers ();
|
||||
|
||||
mg_TerminateTimer (TRUE);
|
||||
mg_TerminateTimer ();
|
||||
|
||||
unlink (CS_PATH);
|
||||
}
|
||||
@@ -365,14 +351,6 @@ BOOL server_IdleHandler4Server (PMSGQUEUE msg_queue, BOOL wait)
|
||||
EXTRA_INPUT_EVENT extra; // Since 4.0.0; for extra input events
|
||||
int nevts = 0; // Since 5.0.0; for timer and fd events
|
||||
|
||||
#if 0 /* deprecated code */
|
||||
/* since 5.0.0, use __mg_update_tick_count instead */
|
||||
if (__mg_tick_counter != SHAREDRES_TIMER_COUNTER) {
|
||||
__mg_tick_counter = SHAREDRES_TIMER_COUNTER;
|
||||
AlertDesktopTimerEvent ();
|
||||
}
|
||||
#endif /* deprecated code */
|
||||
|
||||
/* rset gets modified each time around */
|
||||
rset = __mg_dsk_msg_queue->rfdset;
|
||||
if (__mg_dsk_msg_queue->nr_wfds) {
|
||||
|
||||
@@ -190,14 +190,14 @@ static void ParseEvent (PMSGQUEUE msg_que, int event)
|
||||
BOOL GUIAPI salone_StandAloneStartup (void)
|
||||
{
|
||||
/* VW: do not use signal based interval timer; since 4.0 */
|
||||
mg_InitTimer (FALSE);
|
||||
mg_InitTimer ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void salone_StandAloneCleanup (void)
|
||||
{
|
||||
/* VW: do not use signal based interval timer; since 4.0 */
|
||||
mg_TerminateTimer (FALSE);
|
||||
mg_TerminateTimer ();
|
||||
}
|
||||
|
||||
BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue, BOOL wait)
|
||||
|
||||
Reference in New Issue
Block a user