Exemple #1
0
void st_thread_exit(void *retval)
{
  _st_thread_t *thread = _ST_CURRENT_THREAD();

  thread->retval = retval;
  _st_thread_cleanup(thread);
  _st_active_count--;
  if (thread->term) {
    /* Put thread on the zombie queue */
    thread->state = _ST_ST_ZOMBIE;
    _ST_ADD_ZOMBIEQ(thread);

    /* Notify on our termination condition variable */
    st_cond_signal(thread->term);

    /* Switch context and come back later */
    _ST_SWITCH_CONTEXT(thread);

    /* Continue the cleanup */
    st_cond_destroy(thread->term);
    thread->term = NULL;
  }

#ifdef DEBUG
  _ST_DEL_THREADQ(thread);
#endif

  if (!(thread->flags & _ST_FL_PRIMORDIAL))
    _st_stack_free(thread->stack);

  /* Find another thread to run */
  _ST_SWITCH_CONTEXT(thread);
  /* Not going to land here */
}
Exemple #2
0
/*
 * Increments the value of the semaphore and wakes up any threads waiting on it
 */
void up(semaphore * s) {
    MUTEX_DOWN(s->mutex);
    s->value++;
    MUTEX_UP(s->mutex);

    /* signal is a no op if no thread is waiting */
    st_cond_signal(s->cvar);
}
Exemple #3
0
static void* doneTask(void* arg) {
	int rc = 0;
	--workingNum;
	if ((rc = st_cond_signal(cond)) != 0) {
		std::cout << "st_cond_signal " << rc << " " << strerror(rc) << std::endl;
		return NULL;
	}
	return NULL;
}
Exemple #4
0
void
hoxDbClient::set_player_info( const hoxPlayer_SPtr player,
                              const std::string&   sGameResult )
{
    const std::string sPlayerId = player->getId();

    hoxRequest_SPtr pRequest( new hoxRequest( hoxREQUEST_DB_PLAYER_SET ) );
    pRequest->setParam("pid", sPlayerId);
    pRequest->setParam("score", hoxUtil::intToString(player->getScore()));
    pRequest->setParam("result", sGameResult);

    s_requestList.push_back( pRequest );
    st_cond_signal( s_writeCond );
}
Exemple #5
0
	void notify()
	{
		if(_notify_cond) st_cond_signal(_notify_cond);
	}