コード例 #1
0
/**
 * Unblocks Java thread that monitors specified event queue.
 *
 * @param queueId queue ID
 */
static void unblockMonitorThread(jint queueId) {
    EventQueue* pEventQueue;
    jint isolateId;
    JVMSPI_ThreadID thread;
    
    GET_EVENT_QUEUE_BY_ID(pEventQueue, queueId);

    if (IS_ISOLATE_QUEUE(queueId)) {
        /*
         * 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.
         */
        isolateId = QUEUE_ID_TO_ISOLATE_ID(queueId);
        thread = SNI_GetSpecialThread(isolateId);
        if (thread != NULL) {
            midp_thread_unblock(thread);
        } else {
            REPORT_CRIT(LC_CORE,
                "StoreMIDPEventInVmThread: cannot find "
                "native event monitor thread");
        }
    } else {
        /* Unblock thread in the normal (slower) way */
        midp_thread_signal(EVENT_QUEUE_SIGNAL, queueId, 0);
    }

    pEventQueue->isMonitorBlocked = KNI_FALSE;    
}
コード例 #2
0
ファイル: midpEvents.c プロジェクト: sfsy1989/j2me
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);
            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();
}