37 #if __NC_TASKS_MONITOR
39 #if __NC_TASKS_INTR_SET
48 typedef intr::set< CSrvTask, intr::compare< SrvTaskCompare > > TAllTasksSet;
50 typedef intr::member_hook<CSrvTask, intr::set_member_hook<>, &CSrvTask::m_intr_member_hook> TAllTasksSetOption;
51 typedef intr::set< CSrvTask, TAllTasksSetOption, intr::compare< SrvTaskCompare > > TAllTasksSet;
54 typedef std::set<const CSrvTask*> TAllTasksSet;
57 TAllTasksSet s_all_tasks;
70 #if __NC_TASKS_MONITOR
71 s_all_tasks_lock.
Lock();
72 #if __NC_TASKS_INTR_SET
73 s_all_tasks.insert(*
this);
75 s_all_tasks.insert(
this);
78 m_TaskName =
"CSrvTask";
88 #if __NC_TASKS_MONITOR
89 s_all_tasks_lock.
Lock();
90 #if __NC_TASKS_INTR_SET
91 s_all_tasks.erase(*
this);
93 s_all_tasks.erase(
this);
107 #if __NC_TASKS_MONITOR
110 string is(
"\": "), eol(
",\n\"");
115 s_all_tasks_lock.
Lock();
117 ITERATE(TAllTasksSet,
t, s_all_tasks) {
118 #if __NC_TASKS_INTR_SET
123 if (busy_tasks.
find(job->m_TaskName) == busy_tasks.
end()) {
124 busy_tasks[job->m_TaskName].Initialize();
126 if (idle_tasks.
find(job->m_TaskName) == idle_tasks.
end()) {
127 idle_tasks[job->m_TaskName] = 0;
132 ++idle_tasks[job->m_TaskName];
136 s_all_tasks_lock.
Unlock();
151 : m_TransState(eState_Initial)
153 #if __NC_TASKS_MONITOR
154 m_TaskName =
"CSrvTransitionTask";
161 SRV_FATAL(
"CSrvTransitionTask destructor unexpected: m_TransState: "
206 while (!cons_list.empty()) {
208 cons_list.pop_front();
225 : m_TransFinished(
false)
227 #if __NC_TASKS_MONITOR
228 m_TaskName =
"CSrvTransConsumer";
Uint4 GetDefaultTaskPriority(void)
Mutex created to have minimum possible size (its size is 4 bytes) and to sleep using kernel capabilit...
void Unlock(void)
Unlock the mutex.
void Lock(void)
Lock the mutex.
Task controlling a socket.
CSrvSocketTask & WriteText(CTempString message)
Write text into socket.
CSrvSocketTask & WriteNumber(NumType num)
Write number into socket as string, i.e.
Main working entity in TaskServer.
TSrvTaskFlags m_TaskFlags
Bit-OR of flags for this task.
int m_LastActive
Time (in seconds) when the task was active last time, i.e.
static void PrintState(CSrvSocketTask &task)
CRequestContext ** m_DiagChain
Nested diagnostic contexts of this task.
STimerTicket * m_Timer
Timer ticket assigned to this task when it calls RunAfter().
CRequestContext * m_DiagCtx
Current diagnostic context for this task.
virtual void ExecuteSlice(TSrvThreadNum thr_num)=0
This is the main method to do all work this task should do.
void SetRunnable(bool boost=false)
Set this task "runnable", i.e.
virtual void InternalRunSlice(TSrvThreadNum thr_num)
This is the real time slice execution method called from TaskServer.
Class incorporating convenient methods to work with struct timespec.
static int CurSecs(void)
Current time in seconds since epoch (time_t).
Consumer of notification about transition completeness in CSrvTransitionTask.
virtual ~CSrvTransConsumer(void)
bool m_TransFinished
Flag showing that transition was already consumed.
virtual ~CSrvTransitionTask(void)
void RequestTransition(CSrvTransConsumer *consumer)
Requests task's state transition with the provided consumer to be notified when transition is finishe...
void FinishTransition(void)
Finish the transition process and change task's state from "Transition" to "Final" with notification ...
CMiniMutex m_TransLock
Mutex to protect state changing.
TSrvConsList m_Consumers
Consumers waiting for transition to complete.
ETransState m_TransState
Current state of the task.
void CancelTransRequest(CSrvTransConsumer *consumer)
Cancel transition request from the provided consumer.
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
intr::list< CSrvTransConsumer, intr::base_hook< TSrvConsListHook >, intr::constant_time_size< false > > TSrvConsList
Uint2 TSrvThreadNum
Type for thread number in TaskServer.