KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_midp_chameleon_skins_resources_SkinResourcesImpl_shareResourcePool) { #if ENABLE_MULTIPLE_ISOLATES KNI_StartHandles(1); KNI_DeclareHandle(obj); KNI_GetParameterAsObject(1, obj); if (resourcePool == -1) { /* * We only ever allow a single resource pool to be stored. * Any future attempts at storing a new one are ignored */ resourcePool = SNI_AddStrongReference(obj); } KNI_EndHandles(); #endif KNI_ReturnVoid(); }
/** * private native void send0(LinkMessage msg) * throws ClosedLinkException, * InterruptedIOException, * IOException; */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_links_Link_send0(void) { rendezvous *rp; KNI_StartHandles(3); KNI_DeclareHandle(thisObj); KNI_DeclareHandle(messageObj); KNI_DeclareHandle(otherMessageObj); KNI_GetThisPointer(thisObj); KNI_GetParameterAsObject(1, messageObj); rp = getNativePointer(thisObj); if (rp == NULL) { if (SNI_GetReentryData(NULL) == NULL) { KNI_ThrowNew(midpClosedLinkException, NULL); } else { KNI_ThrowNew(midpInterruptedIOException, NULL); } } else if (JVM_CurrentIsolateID() != rp->sender) { KNI_ThrowNew(midpIllegalArgumentException, NULL); } else { switch (rp->state) { case IDLE: rp->msg = SNI_AddStrongReference(messageObj); rp->state = SENDING; midp_thread_wait(LINK_READY_SIGNAL, (int)rp, NULL); break; case RECEIVING: rp->msg = SNI_AddStrongReference(messageObj); rp->state = RENDEZVOUS; midp_thread_signal(LINK_READY_SIGNAL, (int)rp, 0); midp_thread_wait(LINK_READY_SIGNAL, (int)rp, NULL); break; case SENDING: case RENDEZVOUS: midp_thread_wait(LINK_READY_SIGNAL, (int)rp, NULL); break; case DONE: getReference(rp->msg, "send0/DONE", otherMessageObj); if (KNI_IsSameObject(messageObj, otherMessageObj)) { /* it's our message, finish processing */ SNI_DeleteReference(rp->msg); rp->msg = INVALID_REFERENCE_ID; rp->state = IDLE; midp_thread_signal(LINK_READY_SIGNAL, (int)rp, 0); if (rp->retcode != OK) { KNI_ThrowNew(midpIOException, NULL); } } else { /* somebody else's message, just go back to sleep */ midp_thread_wait(LINK_READY_SIGNAL, (int)rp, NULL); } break; case CLOSED: setNativePointer(thisObj, NULL); if (rp->msg != INVALID_REFERENCE_ID) { /* a message was stranded in the link; clean it out */ SNI_DeleteReference(rp->msg); rp->msg = INVALID_REFERENCE_ID; } rp_decref(rp); if (SNI_GetReentryData(NULL) == NULL) { KNI_ThrowNew(midpClosedLinkException, NULL); } else { KNI_ThrowNew(midpInterruptedIOException, NULL); } break; } } KNI_EndHandles(); KNI_ReturnVoid(); }