Example #1
0
Block MergeTreeBaseBlockInputStream::readImpl()
{
    Block res;

    while (!res && !isCancelled())
    {
        if (!task && !getNewTask())
            break;

        res = readFromPart();

        if (res)
            injectVirtualColumns(res);

        if (task->mark_ranges.empty())
            task.reset();
    }

    return res;
}
Example #2
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;
}
Example #3
0
/**
 * This function processes the image block and it's called whenener a new thread is created
 * @param arg params of the function
 * 
 * @return void
 */ 
void *process_block(void *arg)
{
	PARAM_T *param_ptr = (PARAM_T *) arg; 
	//int i;
	int new_task;
	int match_block;

	int finito = 0;
	while (finito == 0)
	{
		new_task = getNewTask(param_ptr);
		if (new_task == -1)
		{
			finito = 1;
			break;
		}
		match_block = encodeBlockimgX(new_task, param_ptr->pgm_struct, param_ptr->dic_struct, param_ptr->num_blocks_per_line);
		param_ptr->cod_struct.indexVector_ptr[new_task] = match_block;
		
	}
	return NULL;
}
Example #4
0
unsigned int CEncoderThread::ThreadMethod()
{
	par2::PostPar2Volumes* task = NULL;
	
	CMainFrame* pMainFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
	CString progress;

	while (!m_STOP)
	{
		task = getNewTask();
		if (task==NULL || m_STOP) break;
		{
			CSingleLock lock(&m_Mutex,TRUE);
			stat_VolumeFiles.RemoveAll();
			for (int k=0;k<task->nb_vol_files;k++)
				stat_VolumeFiles.Add(task->vol_files_name[k]);
			stat_CurrentFile[0]='\0';
			stat_CurrentFileNum = 0;
			stat_TotalFiles = task->sources->nbfiles;
			stat_CurrentPer1000 = 0;
			++stat_numbatch;
			stat_octets_processed = 0;
		}

		int f=0;
		par2::u64 ofs,size;
		task->GetNextFragmentInfo(&f,&ofs,&size);

		while (f<task->sources->nbfiles && !m_STOP)
		{
			stat_CurrentFileNum = f;
			//memset(stat_CurrentFile,0,_MAX_PATH);
			//strncpy(stat_CurrentFile,task->sources->files[f].name,_MAX_PATH);
			stat_CurrentPer1000 = 0;
			_snprintf(stat_CurrentFile,_MAX_PATH,"Processing file %s...",trimdir(task->sources->files[f].name));
			//pMainFrame->SetStatusText(progress);
			if (!task->ProcessFile(f,m_STOP,stat_CurrentPer1000,stat_octets_processed)) break;
			++f;
			stat_CurrentPer1000 = 1000;
		}
		stat_CurrentFileNum = f;
		stat_CurrentPer1000 = 0;
/*
		if (m_STOP && task->isReady())
		{
			task->errorMsg == "Stopped.";
		}
*/
		if (task->isReady())
		{ // finished
			//progress.Format("Finishing encoding batch...");
			//pMainFrame->SetStatusText(progress);
			_snprintf(stat_CurrentFile,_MAX_PATH,"Finalizing...");
			task->Finish(stat_CurrentPer1000);
			stat_CurrentPer1000 = 1000;
			_snprintf(stat_CurrentFile,_MAX_PATH,"Done.");
		}
		{
			CSingleLock lock(&m_Mutex,TRUE);
			stat_VolumeFiles.RemoveAll();
			stat_CurrentFile[0]='\0';
			stat_CurrentFileNum = 0;
			stat_TotalFiles = 0;
			stat_CurrentPer1000 = 0;
			stat_CurrentPer1000 = 1000;
			++stat_numbatch;
			stat_octets_processed = 0;
		}
		if (!m_STOP)
		{
			sendCompletedTask(task);
			task = NULL;
		}
	}

	if (task!=NULL && task->errorMsg.GetLength()==0)
	{
		task->errorMsg = "Stopped.";
	}

	sendStopped(task);
	return 0;	
}