Exemple #1
0
UserCore::ItemTask::BaseItemTask* ItemThread::getNewTask()
{
    if (isPaused())
        return NULL;

    UserCore::ItemTask::BaseItemTask* task = NULL;

    m_TaskMutex.lock();

    if (m_vTaskList.size() != 0)
    {
        task = m_vTaskList.front();
        m_vTaskList.pop_front();

        gcString name = m_szBaseName;
        name += " - ";
        name += task->getTaskName();

        this->setThreadName(name.c_str());
    }

    m_TaskMutex.unlock();

    return task;
}
Exemple #2
0
bool ItemThread::performTask()
{
	if (isStopped())
		return true;

	UserCore::ItemTask::BaseItemTask* task = getNewTask();

	if (!task)
		return false;

	ITEM_STAGE taskType;

	{
		std::lock_guard<std::mutex> guard(m_DeleteMutex);
		m_bDeleteCurrentTask = false;
		taskType = task->getTaskType();
		m_pCurrentTask = task;
	}

	if (!m_bDeleteCurrentTask)
	{
		m_bRunningTask = true;
		onTaskStartEvent(taskType);

		gcTrace("Task {0}", task->getTaskName());
		task->doTask();

		onTaskCompleteEvent(taskType);
		m_bRunningTask = false;
	}

	{
		std::lock_guard<std::mutex> guard(m_DeleteMutex);
		m_pCurrentTask = nullptr;
	}

	safe_delete(task);
	setThreadName(m_szBaseName.c_str());
	
	return true;
}
Exemple #3
0
bool ItemThread::performTask()
{
    if (isStopped())
        return true;

    UserCore::ItemTask::BaseItemTask* task = getNewTask();

    if (!task)
        return false;

    m_DeleteMutex.lock();
    m_bDeleteCurrentTask = false;
    m_DeleteMutex.unlock();

    uint32 taskType = task->getTaskType();

    m_DeleteMutex.lock();
    m_pCurrentTask = task;
    m_DeleteMutex.unlock();

    if (!m_bDeleteCurrentTask)
    {
        m_bRunningTask = true;
        onTaskStartEvent(taskType);

        task->doTask();

        onTaskCompleteEvent(taskType);
        m_bRunningTask = false;
    }

    m_DeleteMutex.lock();
    m_pCurrentTask = NULL;
    m_DeleteMutex.unlock();

    safe_delete(task);
    setThreadName(m_szBaseName.c_str());

    return true;
}
Exemple #4
0
UserCore::ItemTask::BaseItemTask* ItemThread::getNewTask()
{
	if (isPaused())
		return nullptr;

	UserCore::ItemTask::BaseItemTask* task = nullptr;

	std::lock_guard<std::mutex> guard(m_TaskMutex);
	
	if (m_vTaskList.size() != 0)
	{
		task = m_vTaskList.front();
		m_vTaskList.pop_front();

		gcString name = m_szBaseName;
		name += " - ";
		name += task->getTaskName();

		this->setThreadName(name.c_str());
	}
	
	return task;
}