NCBI C++ ToolKit
threads_man.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef NETCACHE__THREADS_MAN__HPP
2 #define NETCACHE__THREADS_MAN__HPP
3 /* $Id: threads_man.hpp 76997 2017-03-17 13:19:30Z gouriano $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Pavel Ivanov
29  *
30  * File Description:
31  */
32 
33 
34 #include "scheduler.hpp"
35 
36 #ifdef NCBI_OS_LINUX
37 # include <pthread.h>
38 #endif
39 
40 
42 
43 
44 struct SMMMemPoolsSet;
45 struct SLogData;
46 struct SRCUInfo;
47 struct SSchedInfo;
48 struct SSocketsData;
49 class CSrvStat;
50 
51 
52 void InitCurThreadStorage(void);
54 void ConfigureThreads(const CNcbiRegistry* reg, CTempString section);
55 bool ReConfig_Threads(const CTempString& section, const CNcbiRegistry& new_reg, string& err_message);
57 bool InitThreadsMan(void);
58 void RunMainThread(void);
59 void FinalizeThreadsMan(void);
64 
65 
66 
75 };
76 
77 struct SSrvThread : public CSrvRCUUser
78 {
81  int seen_secs;
84 #ifdef NCBI_OS_LINUX
85  pthread_t thread_handle;
86 #endif
94 
95 
96  SSrvThread(void);
97  virtual ~SSrvThread(void);
98 
99 private:
100  virtual void ExecuteRCU(void);
101 };
102 
103 
111 };
112 
113 
114 //////////////////////////////////////////////////////////////////////////
115 // Inline functions
116 //////////////////////////////////////////////////////////////////////////
117 
118 inline bool
120 {
121  return thr->thread_state <= eThreadRevived;
122 }
123 
125 
126 #endif /* NETCACHE__THREADS_MAN__HPP */
CNcbiRegistry –.
Definition: ncbireg.hpp:913
Class to derive from to use RCU mechanism.
Definition: task_server.hpp:75
Task controlling a socket.
Main working entity in TaskServer.
Definition: srv_tasks.hpp:88
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
EServerState
Definition: srv_inlines.hpp:47
Definition: rcu.cpp:41
Per-thread structure containing information about sockets.
SSocketsData * socks
Definition: threads_man.hpp:92
SSrvThread(void)
EServerState seen_srv_state
Definition: threads_man.hpp:83
EThreadState thread_state
Definition: threads_man.hpp:82
Uint8 seen_jiffy
Definition: threads_man.hpp:80
CSrvStat * stat
Definition: threads_man.hpp:93
virtual void ExecuteRCU(void)
Method implementing RCU job that was scheduled earlier by CallRCU().
SSchedInfo * sched
Definition: threads_man.hpp:89
CSrvTask * cur_task
Definition: threads_man.hpp:87
virtual ~SSrvThread(void)
SRCUInfo * rcu
Definition: threads_man.hpp:91
SMMMemPoolsSet * mm_pool
Definition: threads_man.hpp:88
TSrvThreadNum thread_num
Definition: threads_man.hpp:79
SLogData * log_data
Definition: threads_man.hpp:90
Uint2 TSrvThreadNum
Type for thread number in TaskServer.
Definition: task_server.hpp:42
CRef< CTestThread > thr[k_NumThreadsMax]
Definition: test_mt.cpp:267
TSrvThreadNum GetCntRunningThreads(void)
void RequestThreadStart(SSrvThread *thr)
void RunMainThread(void)
bool IsThreadRunning(SSrvThread *thr)
void RequestThreadStop(SSrvThread *thr)
SSrvThread * GetCurThread(void)
Definition: threads_man.cpp:82
EThreadState
Definition: threads_man.hpp:67
@ eThreadStopped
Definition: threads_man.hpp:72
@ eThreadStarting
Definition: threads_man.hpp:68
@ eThreadLockedForStop
Definition: threads_man.hpp:71
@ eThreadRevived
Definition: threads_man.hpp:70
@ eThreadReleased
Definition: threads_man.hpp:73
@ eThreadDormant
Definition: threads_man.hpp:74
@ eThreadRunning
Definition: threads_man.hpp:69
void ConfigureThreads(const CNcbiRegistry *reg, CTempString section)
void InitCurThreadStorage(void)
bool InitThreadsMan(void)
EThreadMgrState
@ eThrMgrIdle
@ eThrMgrThreadExited
@ eThrMgrStarting
@ eThrMgrSocksMoved
@ eThrMgrNeedNewThread
@ eThrMgrPreparesToStop
void RequestThreadRevive(SSrvThread *thr)
void WriteSetup_Threads(CSrvSocketTask &task)
void FinalizeThreadsMan(void)
bool ReConfig_Threads(const CTempString &section, const CNcbiRegistry &new_reg, string &err_message)
Modified on Tue May 21 10:55:30 2024 by modify_doxy.py rev. 669887