Example #1
0
/* {{{ unset state bits on a thread */
int pthreads_unset_state(PTHREAD thread, int mask TSRMLS_DC){
	int result = 0;
	
	if (mask & PTHREADS_ST_WAITING) {
		if (pthreads_state_unset(thread->state, mask TSRMLS_CC)) {
			result = pthreads_synchro_notify(thread->synchro TSRMLS_CC);
		} else result = 0;
	} else result = pthreads_state_unset(thread->state, mask TSRMLS_CC);
	
	return result;
} /* }}} */
Example #2
0
/* {{{ unset state bits on a thread */
int pthreads_unset_state(PTHREAD thread, int mask){
	int wacquire = 0;
	
	pthreads_state_unset(thread->state, mask);
	
	switch(mask) {
		case PTHREADS_ST_WAITING: {
			wacquire = PTHREADS_WLOCK(thread);
			
			if (wacquire == SUCCESS || wacquire == EDEADLK) {
				if (pthread_cond_signal(thread->sync)!=SUCCESS) {
					zend_error(E_WARNING, "pthreads failed to notify %lu", thread->tid);
				}
					
				if (wacquire != EDEADLK) {
					PTHREADS_WUNLOCK(thread);
				}
			} else zend_error(E_WARNING, "pthreads failed to acquire wait lock");
		} break;
		
		case PTHREADS_ST_RUNNING: 
			pthreads_globals_del(thread); 
		break;
	}

	return SUCCESS;
} /* }}} */