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

Go to the SVN repository for this file.

1 #ifndef WN_COMMIT_THREAD__HPP
2 #define WN_COMMIT_THREAD__HPP
3 
4 
5 /* $Id: wn_commit_thread.hpp 92104 2020-12-22 16:06:57Z sadyrovr $
6  * ===========================================================================
7  *
8  * PUBLIC DOMAIN NOTICE
9  * National Center for Biotechnology Information
10  *
11  * This software/database is a "United States Government Work" under the
12  * terms of the United States Copyright Act. It was written as part of
13  * the author's official duties as a United States Government employee and
14  * thus cannot be copyrighted. This software/database is freely available
15  * to the public for use. The National Library of Medicine and the U.S.
16  * Government have not placed any restriction on its use or reproduction.
17  *
18  * Although all reasonable efforts have been taken to ensure the accuracy
19  * and reliability of the software and data, the NLM and the U.S.
20  * Government do not and cannot warrant the performance or results that
21  * may be obtained by using this software or data. The NLM and the U.S.
22  * Government disclaim all warranties, express or implied, including
23  * warranties of performance, merchantability or fitness for any particular
24  * purpose.
25  *
26  * Please cite the author in any work or product based on this material.
27  *
28  * ===========================================================================
29  *
30  * Authors: Dmitry Kazimirov
31  *
32  * File Description:
33  * NetSchedule Worker Node - job committer thread, declarations.
34  */
35 
37 
38 #include <deque>
39 
41 
42 /////////////////////////////////////////////////////////////////////////////
43 //
44 /// @internal
46 {
47 public:
49 
51  : m_SavedRequestContext(&CDiagContext::GetRequestContext())
52  {
53  CDiagContext::SetRequestContext(new_request_context);
54  }
55 
56  void Release()
57  {
61  }
62  }
63 
65  {
66  Release();
67  }
68 
69 private:
71 };
72 
73 /////////////////////////////////////////////////////////////////////////////
74 //
75 /// @internal
77 {
78 public:
80 
82 
84  CRequestContextSwitcher& rctx_switcher);
85 
86  void Stop();
87 
88 private:
90  typedef deque<TEntry> TCommitJobTimeline;
91 
92  virtual void* Main();
93 
94  bool WaitForTimeout();
95  bool x_CommitJob(SWorkerNodeJobContextImpl* job_context);
96 
97  void WakeUp()
98  {
99  if (m_ImmediateActions.empty())
100  m_Semaphore.Post();
101  }
102 
107  const string m_ThreadName;
108  bool m_IsShuttingDown = false;
109 
112 };
113 
115 
116 #endif // WN_COMMIT_THREAD__HPP
CFastMutex –.
Definition: ncbimtx.hpp:667
CGuard< CFastMutex, SSimpleUnlock< CFastMutex >, SSimpleLock< CFastMutex > > TFastMutexUnlockGuard
deque< TEntry > TCommitJobTimeline
SGridWorkerNodeImpl * m_WorkerNode
CJobCommitterThread(SGridWorkerNodeImpl *worker_node)
CRef< SWorkerNodeJobContextImpl > TEntry
TCommitJobTimeline m_JobContextPool
void RecycleJobContextAndCommitJob(SWorkerNodeJobContextImpl *job_context, CRequestContextSwitcher &rctx_switcher)
virtual void * Main()
Derived (user-created) class must provide a real thread function.
TCommitJobTimeline m_Timeline
TCommitJobTimeline m_ImmediateActions
bool x_CommitJob(SWorkerNodeJobContextImpl *job_context)
CWorkerNodeJobContext AllocJobContext()
CRequestContextSwitcher(CRequestContext *new_request_context)
CRef< CRequestContext > m_SavedRequestContext
CSemaphore –.
Definition: ncbimtx.hpp:1375
Worker Node job context.
Grid Framework specs.
static void SetRequestContext(CRequestContext *ctx)
Shortcut to CDiagContextThreadData::GetThreadData().SetRequestContext()
Definition: ncbidiag.cpp:1907
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void Post(unsigned int count=1)
Increment the semaphore by "count".
Definition: ncbimtx.cpp:1971
SSimpleLock is a functor to wrap calling Lock().
Definition: guard.hpp:49
Modified on Wed Apr 17 13:08:46 2024 by modify_doxy.py rev. 669887