📄 events.h
字号:
/*******************************************************************************
* Modification Notice:
* --------------------------
* This software is modified by MediaTek Inc. and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*******************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
*
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
*
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*
* Copyright (c) 1998-2002 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* Use is subject to license terms.
*/
/*=========================================================================
* SYSTEM: KVM
* SUBSYSTEM: Event handling support
* FILE: events.h
* OVERVIEW: This file defines the macros and operations for
* binding the interpreter to the event handling
* mechanisms of the host operating system in a
* portable fashion.
* AUTHOR: Nik Shaylor 4/20/2000
* Original Palm OS specific implementation by Doug Simon 1998
*=======================================================================*/
/*=========================================================================
* Include files
*=======================================================================*/
/*=========================================================================
* Event system macros
*=======================================================================*/
/*=========================================================================
* Thread scheduling macros.
* These are here to isolate the scheduling code out of interpret.c.
* Note that the thread switching macros are normally used also for
* driving the event handling/polling mechanism,
*=======================================================================*/
/*
* Indicate task switching is necessary
* (enforce a thread switch)
*/
#define signalTimeToReschedule() (Timeslice = 0)
/*
* Determine if it is time to reschedule
*/
#define isTimeToReschedule() (Timeslice-- == 0)
/*
* Added by Justin. Use it on the function that spends much time.
*/
#define decreaseTimeSlice10() \
Timeslice -= 10; \
if(Timeslice < 0) Timeslice = 0;
#define decreaseTimeSlice50() \
Timeslice -= 50; \
if(Timeslice < 0) Timeslice = 0;
/*
* Check that the time slice value is not junk
* (should never happen)
*/
#if INCLUDEDEBUGCODE
#define checkRescheduleValid() if (Timeslice < 0) \
{ fatalError(KVM_MSG_INVALID_TIMESLICE); }
#else
#define checkRescheduleValid() /**/
#endif /* INCLUDEDEBUGCODE */
/*
* InterpreterHandleEvent
*
* This function ties the virtual machine with events coming
* from the host operating system. Since CLDC itself does
* not define any event handling capabilities, the function
* pretty much empty in those builds that don't include any
* additional classes beyond CLDC.
*
*/
void InterpreterHandleEvent(ulong64);
/*
* __ProcessDebugCmds()
*
* This function ties the virtual machine with the new
* Java-level debugger interface.
*/
#if ENABLE_JAVA_DEBUGGER
#define __ProcessDebugCmds(x) ProcessDebugCmds(x)
#else
#define __ProcessDebugCmds(x)
#endif /* ENABLE_JAVA_DEBUGGER */
/*
* Reschedule
*
* This routine is called from inside the interpreter when
* it is time to perform thread switching.
*
*/
extern int checkEventCountTimeSlice;
#define reschedule() \
checkEventCountTimeSlice --; \
if(checkEventCountTimeSlice <= 0){ \
checkEventCountTimeSlice = EVENTTIMESLICECOUNT; \
checkEventOver(); \
} \
do { \
ulong64 wakeupTime; \
if (!areAliveThreads()) { \
return; /* end of program */ \
} \
checkTimerQueue(&wakeupTime); \
InterpreterHandleEvent(wakeupTime); \
__ProcessDebugCmds(0); \
} while (!SwitchThread());
/*=========================================================================
* Event handling functions
*=======================================================================*/
extern int eventCount; /* Number of events on event queue */
void InitializeEvents(void);
BOOL StoreKVMEvent(cell type, int argCount, /* cell cell cell */ ... );
/*
* GetAndStoreNextKVMEvent
*
* Platform-specific function for reading events from the host
* operating system. This function typically needs to be ported
* to use the low-level event handling mechanisms of the host
* platform.
*
*/
extern void j2me_vm_get_nextevent(bool_t forever, ulong64 wait_until, bool_t sys_event_only);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -