46 # include <sys/prctl.h>
67 static pthread_key_t s_CurThreadKey;
98 return thr->thread_num - 1;
116 pthread_setspecific(s_CurThreadKey,
thr);
120 else if (
thr->thread_num == 0)
124 prctl(PR_SET_NAME, (
unsigned long)
buf, 0, 0, 0);
134 thr->stat->ThreadStarted();
267 int res = pthread_create(&
thr->thread_handle,
NULL, thr_func, (
void*)
thr);
335 if (next_jfy_time > cur_time) {
337 wait_time -= cur_time;
422 pthread_join(
thr->thread_handle,
NULL);
434 int res = pthread_key_create(&s_CurThreadKey,
NULL);
436 printf(
"terminating after pthread_key_create returned error %d\n", res);
437 SRV_FATAL(
"pthread_key_create returned error: " << res);
457 string is(
"\": "), eol(
",\n\"");
void SchedStartJiffy(SSrvThread *thr)
void ReleaseThreadSched(SSrvThread *thr)
void AssignThreadSched(SSrvThread *thr)
void SchedCheckOverloads(void)
void SchedExecuteTask(SSrvThread *thr)
Wrapper around Linux's futex.
EWaitResult WaitValueChange(int old_value)
Wait for futex's value to change (with and without timeout).
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.
Class incorporating convenient methods to work with struct timespec.
static int CurSecs(void)
Current time in seconds since epoch (time_t).
static CSrvTime Current(void)
Exact current time with precision up to nanoseconds.
static void RequestShutdown(ESrvShutdownType shutdown_type)
Asks server to start shutdown procedures.
static TSrvThreadNum GetCurThreadNum(void)
Returns number of current worker thread. Number is 0-based.
static bool IsInShutdown(void)
Checks if TaskServer received request to shutdown.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
void Critical(CExceptionArgs_Base &args)
uint64_t Uint8
8-byte (64-bit) unsigned integer
virtual int GetInt(const string §ion, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get integer value of specified parameter name.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void AssignThreadLogging(SSrvThread *thr)
void CheckLoggingFlush(SSrvThread *thr)
void LogNoteThreadsStarted(void)
void ReleaseThreadLogging(SSrvThread *thr)
void StartThreadLogging(SSrvThread *thr)
void StopThreadLogging(SSrvThread *thr)
void AssignThreadMemMgr(SSrvThread *thr)
void ReleaseThreadMemMgr(SSrvThread *thr)
Process information in the NCBI Registry, including working with configuration files.
bool RCUHasCalls(SRCUInfo *rcu)
void RCUFinalizeThread(SSrvThread *thr)
void RCUInitNewThread(SSrvThread *thr)
void RCUPassQS(SRCUInfo *rcu)
void TrackShuttingDown(void)
void CheckConnectsTimeout(SSocketsData *socks)
void ReleaseThreadSocks(SSrvThread *thr)
void MoveAllSockets(SSocketsData *dst_socks, SSocketsData *src_socks)
void AssignThreadSocks(SSrvThread *thr)
void CleanSocketList(SSocketsData *socks)
void SetAllSocksRunnable(SSocketsData *socks)
void PromoteSockAmount(SSocketsData *socks)
#define SRV_LOG(sev, msg)
Macro to be used for printing log messages.
bool IsServerStopping(void)
EThreadState thread_state
virtual void ExecuteRCU(void)
Method implementing RCU job that was scheduled earlier by CallRCU().
virtual ~SSrvThread(void)
Uint2 TSrvThreadNum
Type for thread number in TaskServer.
CRef< CTestThread > thr[k_NumThreadsMax]
static CMiniMutex s_ThrMgrLock
TSrvThreadNum GetCntRunningThreads(void)
static void * s_WorkerThreadMain(void *data)
static void s_RegisterNewThread(SSrvThread *thr)
static void s_PerJiffyTasks_Main(SSrvThread *thr)
void RequestThreadStart(SSrvThread *thr)
static void s_StartCurMgrThread(void)
static void s_StopCurMgrThread(void)
static SSrvThread * s_SvcThr
static void s_PerJiffyTasks_Worker(SSrvThread *thr)
static const TSrvThreadNum kMaxNumberOfThreads
void RequestThreadStop(SSrvThread *thr)
SSrvThread * GetCurThread(void)
static SSrvThread * s_MainThr
void ConfigureThreads(const CNcbiRegistry *reg, CTempString section)
void InitCurThreadStorage(void)
static EThreadMgrState s_ThreadMgrState
bool InitThreadsMan(void)
bool ReConfig_Threads(const CTempString &, const CNcbiRegistry &, string &)
TSrvThreadNum s_MaxRunningThreads
void RequestThreadRevive(SSrvThread *thr)
static bool s_StartThread(SSrvThread *thr, void *(*thr_func)(void *))
void WriteSetup_Threads(CSrvSocketTask &task)
void FinalizeThreadsMan(void)
static void s_PerJiffyTasks_Service(SSrvThread *thr)
static void s_SetCurThread(SSrvThread *thr)
static void s_JoinAllThreads(void)
static bool s_StartAllThreads(void)
static SSrvThread * s_CurMgrThread
static CFutex s_SvcSignal
static void * s_ServiceThreadMain(void *)
static SSrvThread * s_AllocThread(TSrvThreadNum thread_num)
bool IsThreadRunning(SSrvThread *thr)
voidp calloc(uInt items, uInt size)