示例#1
0
void enableSuspend(Thread *thread) {
    sigset_t mask;

    thread->blocking = FALSE;
    MBARRIER();

    if(thread->suspend) {
        TRACE("Thread 0x%x id: %d is self suspending\n", thread, thread->id);
        suspendLoop(thread);
        TRACE("Thread 0x%x id: %d resumed\n", thread, thread->id);
    }

    sigemptyset(&mask);
    sigaddset(&mask, SIGUSR1);
    pthread_sigmask(SIG_UNBLOCK, &mask, NULL);
}
示例#2
0
static void suspendHandler(int sig) {
    Thread *thread = threadSelf();
    suspendLoop(thread);
}
示例#3
0
bool OSystem_IPHONE::pollEvent(Common::Event &event) {
	//printf("pollEvent()\n");

	long curTime = getMillis();

	if (_timerCallback && (curTime >= _timerCallbackNext)) {
		_timerCallback(_timerCallbackTimer);
		_timerCallbackNext = curTime + _timerCallbackTimer;
	}

	if (_queuedInputEvent.type != Common::EVENT_INVALID && curTime >= _queuedEventTime) {
		event = _queuedInputEvent;
		_queuedInputEvent.type = Common::EVENT_INVALID;
		return true;
	}

	int eventType;
	int x, y;

	if (iPhone_fetchEvent(&eventType, &x, &y)) {
		switch ((InputEvent)eventType) {
		case kInputMouseDown:
			if (!handleEvent_mouseDown(event, x, y))
				return false;
			break;

		case kInputMouseUp:
			if (!handleEvent_mouseUp(event, x, y))
				return false;
			break;

		case kInputMouseDragged:
			if (!handleEvent_mouseDragged(event, x, y))
				return false;
			break;
		case kInputMouseSecondDragged:
			if (!handleEvent_mouseSecondDragged(event, x, y))
				return false;
			break;
		case kInputMouseSecondDown:
			_secondaryTapped = true;
			if (!handleEvent_secondMouseDown(event, x, y))
				return false;
			break;
		case kInputMouseSecondUp:
			_secondaryTapped = false;
			if (!handleEvent_secondMouseUp(event, x, y))
				return false;
			break;
		case kInputOrientationChanged:
			handleEvent_orientationChanged(x);
			return false;
			break;

		case kInputApplicationSuspended:
			suspendLoop();
			return false;
			break;

		case kInputKeyPressed:
			handleEvent_keyPressed(event, x);
			break;

		case kInputSwipe:
			if (!handleEvent_swipe(event, x))
				return false;
			break;

		default:
			break;
		}

		return true;
	}
	return false;
}