removed some redundant code
This commit is contained in:
parent
44c72e07e6
commit
2cef223f4c
@ -2770,36 +2770,27 @@ static void __interrupt dos_timer_intr_handler (void)
|
||||
_chain_intr (dos_prev_timer_intr_handler);
|
||||
}
|
||||
|
||||
static void moo_start_ticker (void)
|
||||
{
|
||||
if (++ticker_started == 1)
|
||||
static MOO_INLINE void start_ticker (void)
|
||||
{
|
||||
dos_prev_timer_intr_handler = _dos_getvect(0x1C);
|
||||
_dos_setvect (0x1C, dos_timer_intr_handler);
|
||||
}
|
||||
}
|
||||
|
||||
static void moo_stop_ticker (void)
|
||||
{
|
||||
if (ticker_started > 0 && --ticker_started == 0)
|
||||
static MOO_INLINE void moo_stop_ticker (void)
|
||||
{
|
||||
_dos_setvect (0x1C, dos_prev_timer_intr_handler);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
static HANDLE win_tick_timer = MOO_NULL; /*INVALID_HANDLE_VALUE;*/
|
||||
static moo_uint32_t ticker_started = 0;
|
||||
|
||||
static VOID CALLBACK arrange_process_switching (LPVOID arg, DWORD timeLow, DWORD timeHigh)
|
||||
{
|
||||
swproc_all_moos ();
|
||||
}
|
||||
|
||||
static void moo_start_ticker (void)
|
||||
{
|
||||
if (++ticker_started == 1)
|
||||
static MOO_INLINE void start_ticker (void)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
win_tick_timer = CreateWaitableTimer(MOO_NULL, TRUE, MOO_NULL);
|
||||
@ -2809,11 +2800,8 @@ static void moo_start_ticker (void)
|
||||
SetWaitableTimer (win_tick_timer, &li, 0, arrange_process_switching, MOO_NULL, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void moo_stop_ticker (void)
|
||||
{
|
||||
if (ticker_started > 0 && --ticker_started == 0)
|
||||
static MOO_INLINE void stop_ticker (void)
|
||||
{
|
||||
if (win_tick_timer)
|
||||
{
|
||||
@ -2822,14 +2810,12 @@ static void moo_stop_ticker (void)
|
||||
win_tick_timer = MOO_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__OS2__)
|
||||
static TID os2_tick_tid;
|
||||
static HEV os2_tick_sem;
|
||||
static HTIMER os2_tick_timer;
|
||||
static int os2_tick_done = 0;
|
||||
static moo_uint32_t ticker_started = 0;
|
||||
|
||||
static void EXPENTRY os2_wait_for_timer_event (ULONG x)
|
||||
{
|
||||
@ -2862,23 +2848,17 @@ static void EXPENTRY os2_wait_for_timer_event (ULONG x)
|
||||
DosExit (EXIT_THREAD, 0);
|
||||
}
|
||||
|
||||
static void moo_start_ticker (void)
|
||||
{
|
||||
if (++ticker_started == 1)
|
||||
static MOO_INLINE void start_ticker (void)
|
||||
{
|
||||
/* TODO: Error check */
|
||||
DosCreateThread (&os2_tick_tid, os2_wait_for_timer_event, 0, 0, 4096);
|
||||
}
|
||||
}
|
||||
|
||||
static void moo_stop_ticker (void)
|
||||
{
|
||||
if (ticker_started > 0 && --ticker_started == 0)
|
||||
static MOO_INLINE void stop_ticker (void)
|
||||
{
|
||||
if (os2_tick_sem) DosPostEventSem (os2_tick_sem);
|
||||
os2_tick_done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(macintosh)
|
||||
|
||||
@ -2894,7 +2874,7 @@ static pascal void timer_intr_handler (TMTask* task)
|
||||
PrimeTime ((QElem*)&mac_tmtask, TMTASK_DELAY);
|
||||
}
|
||||
|
||||
static void moo_start_ticker (void)
|
||||
static MOO_INLINE void start_ticker (void)
|
||||
{
|
||||
GetCurrentProcess (&mac_psn);
|
||||
memset (&mac_tmtask, 0, MOO_SIZEOF(mac_tmtask));
|
||||
@ -2903,7 +2883,7 @@ static void moo_start_ticker (void)
|
||||
PrimeTime ((QElem*)&mac_tmtask, TMTASK_DELAY);
|
||||
}
|
||||
|
||||
static void moo_stop_ticker (void)
|
||||
static MOO_INLINE void stop_ticker (void)
|
||||
{
|
||||
RmvTime ((QElem*)&mac_tmtask);
|
||||
/*DisposeTimerProc (mac_tmtask.tmAddr);*/
|
||||
@ -2916,11 +2896,8 @@ static void arrange_process_switching (int sig)
|
||||
swproc_all_moos ();
|
||||
}
|
||||
|
||||
static moo_uint32_t ticker_started = 0;
|
||||
|
||||
void moo_start_ticker (void)
|
||||
{
|
||||
if (++ticker_started == 1)
|
||||
static MOO_INLINE void start_ticker (void)
|
||||
{
|
||||
if (set_signal_handler(SIGVTALRM, arrange_process_switching, SA_RESTART) >= 0)
|
||||
{
|
||||
@ -2934,11 +2911,8 @@ void moo_start_ticker (void)
|
||||
setitimer (ITIMER_VIRTUAL, &itv, MOO_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void moo_stop_ticker (void)
|
||||
{
|
||||
if (ticker_started > 0 && --ticker_started == 0)
|
||||
static MOO_INLINE void stop_ticker (void)
|
||||
{
|
||||
/* ignore the signal fired by the activated timer.
|
||||
* unsetting the signal may cause the program to terminate(default action) */
|
||||
@ -2952,7 +2926,6 @@ void moo_stop_ticker (void)
|
||||
setitimer (ITIMER_VIRTUAL, &itv, MOO_NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
# error UNSUPPORTED
|
||||
@ -3410,3 +3383,23 @@ void moo_rcvtickstd (moo_t* moo, int v)
|
||||
xtn_t* xtn = GET_XTN(moo);
|
||||
xtn->rcv_tick = v;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static moo_uint32_t ticker_started = 0;
|
||||
|
||||
void moo_start_ticker (void)
|
||||
{
|
||||
if (++ticker_started == 1)
|
||||
{
|
||||
start_ticker ();
|
||||
}
|
||||
}
|
||||
|
||||
void moo_stop_ticker (void)
|
||||
{
|
||||
if (ticker_started > 0 && --ticker_started == 0)
|
||||
{
|
||||
stop_ticker ();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user