greenplumn CTaskSchedulerFifo 源码
greenplumn CTaskSchedulerFifo 代码
文件路径:/src/backend/gporca/libgpos/src/task/CTaskSchedulerFifo.cpp
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2010 Greenplum, Inc.
//
// @filename:
// CTaskSchedulerFifo.cpp
//
// @doc:
// Implementation of task scheduler with FIFO.
//---------------------------------------------------------------------------
#include "gpos/task/CTaskSchedulerFifo.h"
using namespace gpos;
//---------------------------------------------------------------------------
// @function:
// CTaskSchedulerFifo::Enqueue
//
// @doc:
// Add task to waiting queue
//
//---------------------------------------------------------------------------
void
CTaskSchedulerFifo::Enqueue(CTask *task)
{
m_task_queue.Append(task);
task->SetStatus(CTask::EtsQueued);
}
//---------------------------------------------------------------------------
// @function:
// CTaskSchedulerFifo::Dequeue
//
// @doc:
// Get next task to execute
//
//---------------------------------------------------------------------------
CTask *
CTaskSchedulerFifo::Dequeue()
{
GPOS_ASSERT(!m_task_queue.IsEmpty());
CTask *task = m_task_queue.RemoveHead();
task->SetStatus(CTask::EtsDequeued);
return task;
}
//---------------------------------------------------------------------------
// @function:
// CTaskSchedulerFifo::Cancel
//
// @doc:
// Check if task is waiting to be scheduled and remove it
//
//---------------------------------------------------------------------------
GPOS_RESULT
CTaskSchedulerFifo::Cancel(CTask *task)
{
// iterate until found
CTask *task_it = m_task_queue.First();
while (nullptr != task_it)
{
if (task_it == task)
{
m_task_queue.Remove(task_it);
task_it->Cancel();
return GPOS_OK;
}
task_it = m_task_queue.Next(task_it);
}
return GPOS_NOT_FOUND;
}
// EOF
相关信息
相关文章
greenplumn CAutoSuspendAbort 源码
greenplumn CTaskLocalStorage 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦