midp事件的存储和获取
来源:互联网 发布:mac jenkins安装路径 编辑:程序博客网 时间:2024/06/08 07:10
//midp事件的存储和获取
// 类似消费者
// 获取MIDP事件,保存在pResult中;返回未处理的MIDP事件个数static int
getPendingMIDPEvent(MidpEvent* pResult, int isolateId)
{
// 获取Isolate对应的等待事件队列
// 在MVM模式下,每个Isolate有1个等待事件队列
// 在SVM模式下,有1个等待事件队列
EventQueue* pEventQueue = getIsolateEventQueue(isolateId);
// 队列中的事件个数为0时
if (pEventQueue->numEvents == 0)
{
return -1;
}
// 队列中有事件时,取出队列当前尾部的这个事件
*pResult = pEventQueue->events[pEventQueue->eventOut];
// 取出事件后,对该队列位置元素值进行重新初始化
/* Empty out the events so we do not free it when finalizing. */
MIDP_EVENT_INITIALIZE(pEventQueue->events[pEventQueue->eventOut]);
// 事件计数减1
pEventQueue->numEvents--;
// 取事件位置向后挪一个元素
pEventQueue->eventOut++;
// 循环队列,到达最大个数后,回到初始位置
if (pEventQueue->eventOut == MAX_EVENTS)
{
/* This is a circular queue, so start back at zero. */
pEventQueue->eventOut = 0;
}
// 返回队列当前的事件个数
return pEventQueue->numEvents;
}
// 类似生产者
// 把MIDP事件保存到isolateId对应的事件队列中去
static void StoreMIDPEventInVmThreadImp(MidpEvent event, int isolateId)
{
EventQueue* pEventQueue;
JVMSPI_ThreadID thread;
pEventQueue = getIsolateEventQueue(isolateId);
midp_logThreadId("StoreMIDPEventInVmThread");
// 临界区,加锁
midp_waitAndLockEventQueue();
// 事件队列未满,可继续存储事件
if (pEventQueue->numEvents != MAX_EVENTS)
{
pEventQueue->events[pEventQueue->eventIn] = event;
pEventQueue->eventIn++;
if (pEventQueue->eventIn == MAX_EVENTS) {
/* This is a circular queue, so start back at zero. */
pEventQueue->eventIn = 0;
}
pEventQueue->numEvents++;
if (pEventQueue->isMonitorBlocked)
{
/*
* The event monitor thread has been saved as the "special" thread
* of this particular isolate in order to avoid having to search
* the entire list of threads.
*/
thread = SNI_GetSpecialThread(isolateId);
/* check and align stack suspend/resume state */
// midp_checkAndResume();
if (thread != NULL)
{
midp_thread_unblock(thread);
pEventQueue->isMonitorBlocked = KNI_FALSE;
}
else
{
REPORT_CRIT(LC_CORE,
"StoreMIDPEventInVmThread: cannot find "
"native event monitor thread");
}
}
}
// 事件队列已满,此时发过来的事件将被丢弃!
else
{
/*
* Ignore the event; there is no space to store it.
* IMPL NOTE: this should be fixed, or it should be a fatal error;
* dropping an event can lead to a full system deadlock.
*/
REPORT_CRIT1(LC_CORE,"**event queue %d full, dropping event",isolateId);
}
midp_unlockEventQueue();
}
- midp事件的存储和获取
- MIDP和MIDlet的关系
- 分析MIDP的高级事件处理机制
- KJAVA虚拟机Hack笔记-实现MIDP的SLAVE事件模型
- KJAVA虚拟机移植笔记-MIDP的SLAVE事件流程
- cookie的存储和获取
- 数据库和 MIDP
- 一个MIDP俄罗斯方块游戏的设计和实现
- 一个MIDP俄罗斯方块游戏的设计和实现 (转)
- 一个MIDP俄罗斯方块游戏的设计和实现
- 数据库和 MIDP,第 5 部分:搜索记录存储(ZT)
- MIDP
- ANDROID 触摸屏事件和位置的获取
- Android图片的获取和存储
- Android获取手机和SD卡的存储存储信息
- MIDP和J2ME测试题目
- 深入理解CLDC和MIDP
- 深入理解CLDC和MIDP
- marquee属性的使用说明
- SHAREPOINT 2013 - 单一服务器场工作流构建
- vcredist_x86.exe的参数说明
- 注解学习总结
- ubuntu语言设置为英语
- midp事件的存储和获取
- SQLite字段类型使用注意事项
- Internet信息服务(IIS)管理器之常见错误解决办法
- using (SqlConnection conn = new SqlConnection(connString))
- openssh隧道技术简介
- ListView选项不能点击 的解决办法
- 指纹识别上线 考勤设备联网
- 在ARC项目中使用非ARC框架或者类库的解决方案
- 实现只能输入数字的TextBox