Пример #1
0
/**
 * Delete the server.
 *   @serv: The server.
 */
void web_serv_delete(struct web_serv_t *serv)
{
	sys_task_delete(serv->task);
	sys_mutex_destroy(&serv->sync);
	sys_mutex_destroy(&serv->lock);
	web_client_destroy(serv->client);
	free(serv);
}
Пример #2
0
error_code sys_lwmutex_destroy(ppu_thread& ppu, vm::ptr<sys_lwmutex_t> lwmutex)
{
	sysPrxForUser.trace("sys_lwmutex_destroy(lwmutex=*0x%x)", lwmutex);

	if (g_cfg.core.hle_lwmutex)
	{
		return sys_mutex_destroy(lwmutex->sleep_queue);
	}

	// check to prevent recursive locking in the next call
	if (lwmutex->vars.owner.load() == ppu.id)
	{
		return CELL_EBUSY;
	}

	// attempt to lock the mutex
	if (error_code res = sys_lwmutex_trylock(ppu, lwmutex))
	{
		return res;
	}

	// call the syscall
	if (error_code res = _sys_lwmutex_destroy(lwmutex->sleep_queue))
	{
		// unlock the mutex if failed
		sys_lwmutex_unlock(ppu, lwmutex);

		return res;
	}

	// deleting succeeded
	lwmutex->vars.owner.release(lwmutex_dead);

	return CELL_OK;
}
Пример #3
0
void
sys_threadpool_destroy(sys_threadpool *pool)
{
	size_t i;

	if (!pool)
		return;
	
	pool->shutdown = true;

	sys_threadpool_wait_all(pool, UINT32_MAX);

	sys_msleep(10);

	sys_tls_free_key(pool->worker_key);

	for (i = 0; i < pool->workers.count; ++i)
		sys_thread_destroy(((sys_worker *)rt_array_get(&pool->workers, i))->thread);

	rt_array_release(&pool->workers);
	rt_array_release(&pool->active_tasks);

	rt_queue_release(&pool->task_queue);

	sys_cond_var_destroy(pool->task_notify);
	sys_mutex_destroy(pool->task_mutex);

	free(pool);
}
Пример #4
0
void gsiDeleteCriticalSection(GSICriticalSection *theCrit) 
{ 
	int ret;
	ret = sys_mutex_destroy(*theCrit);
	if (ret != CELL_OK)
	{
		gsDebugFormat(GSIDebugCat_Common, GSIDebugType_Misc, GSIDebugLevel_WarmError,
			"Failed to delete critical section: %d\r\n", ret);
	}
}
Пример #5
0
/**
 * Delete a communication structure.
 *   @comm: The communication structure.
 */
void amp_comm_delete(struct amp_comm_t *comm)
{
	struct inst_t *inst;

	while((inst = comm->inst) != NULL) {
		comm->inst = inst->next;

		amp_midi_close(inst->midi);
		free(inst);
	}

	sys_mutex_destroy(&comm->lock);
	free(comm);
}
RJ_API void rj_m_conn_destroy(rj_net_m_conn_h handle)
{
    rj_net_multi_conn_t *p_m_conn = (rj_net_multi_conn_t *)(handle);
    assert (NULL != p_m_conn);

    if (NULL != p_m_conn)
    {
        while(0 < rj_list_size(p_m_conn->conn_list))
        {
            rj_net_conn_h net_conn = (rj_net_conn_h)(rj_list_pop_front(p_m_conn->conn_list));
            assert (NULL != net_conn);
            rj_conn_destroy(net_conn);
        }

        rj_list_destroy(p_m_conn->conn_list);

        sys_mutex_destroy(p_m_conn->p_sys_mutex);

        sys_free(p_m_conn);//delete p_m_conn;
    }
}
Пример #7
0
sys_threadpool *
sys_threadpool_create(uint32_t num_workers)
{
	sys_threadpool *pool = (sys_threadpool *)calloc(1, sizeof(*pool));
	sys_worker *worker = NULL;
	size_t i;

	if (!pool)
		return NULL;

	pool->task_mutex = sys_mutex_create();
	pool->task_notify = sys_cond_var_create();
	
	pool->num_workers = num_workers;
	pool->shutdown = false;

	if (pool->num_workers <= 0) {
		if ((pool->num_workers = sys_cpu_count()) <= 0) {
			log_entry(THREADPOOL_MODULE, LOG_WARNING, "Failed to determine processor count. Limiting server to one thread. To avoid this, specify the number of threads");
			pool->num_workers = 1;
		}
	}

	if (rt_array_init(&pool->workers, pool->num_workers, sizeof(sys_worker)) != SYS_OK)
		goto free_task;

	if (rt_array_init(&pool->active_tasks, pool->num_workers, sizeof(sys_task *)) != SYS_OK)
		goto free_workers;	

	if (rt_queue_init(&pool->task_queue, (size_t)pool->num_workers * 2, sizeof(sys_task)) != SYS_OK)
		goto free_active_tasks;

	pool->worker_key = sys_tls_alloc_key();

	rt_array_fill(&pool->workers);
	for (i = 0; i < pool->num_workers; ++i) {
		worker = rt_array_get(&pool->workers, i);

		worker->id = i;
		worker->idle = true;
		worker->pool = pool;
		
		worker->thread = sys_thread_create(_threadpool_worker_proc);

		sys_thread_start(worker->thread, worker);
		sys_thread_detach(worker->thread);
	}

	return pool;

free_active_tasks:
	rt_array_release(&pool->active_tasks);

free_workers:
	rt_array_release(&pool->workers);

free_task:
	sys_mutex_destroy(pool->task_mutex);
	sys_cond_var_destroy(pool->task_notify);

	free(pool);

	return NULL;
}
Пример #8
0
						CellMutex::~CellMutex			()
{
	sys_mutex_destroy(Mutex);
}