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

Go to the SVN repository for this file.

1 #ifndef NETSCHEDULE_SCOPE__HPP
2 #define NETSCHEDULE_SCOPE__HPP
3 
4 /* $Id: ns_scope.hpp 72383 2016-05-04 15:52:20Z satskyse $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Sergey Satskiy
30  *
31  * File Description:
32  * Net schedule scopes
33  *
34  */
35 
36 
37 #include <corelib/ncbimtx.hpp>
38 #include <corelib/ncbicntr.hpp>
39 
40 #include "ns_types.hpp"
41 
42 #include <map>
43 #include <vector>
44 
45 
47 
48 
49 // forward declaration
50 class CQueue;
51 
52 
53 // Fixed identifier of a scope to tell that the jobs scope includes
54 // only the jobs without any scope
55 const string kNoScopeOnly = "no-scope-only";
56 
57 
58 
60 {
61  public:
64 
65  size_t size(void) const;
66  bool CanAccept(const string & scope,
67  size_t max_records) const;
68  TNSBitVector GetJobs(const string & scope) const;
69  TNSBitVector GetAllJobsInScopes(void) const;
70  void AddJob(const string & scope,
71  unsigned int job_id);
72  void AddJobs(const string & scope,
73  unsigned int first_job_id,
74  unsigned int count);
75  void RemoveJob(unsigned int job_id);
76  deque<string> GetScopeNames(void) const;
77  string GetJobScope(unsigned int job_id) const;
78 
79  string Print(const CQueue * queue,
80  size_t batch_size,
81  bool verbose) const;
82  void Clear(void);
83 
84  unsigned int CollectGarbage(unsigned int max_to_del);
85  unsigned int CheckRemoveCandidates(void);
86  private:
87  typedef map< string,
89 
90  private:
92 
93  mutable CMutex m_Lock; // Lock for the operations
95 
96  private:
97  string x_PrintOne(const string & scope_name,
98  const TNSBitVector & jobs,
99  const CQueue * queue,
100  bool verbose) const;
101  string x_PrintSelected(const deque<string> & batch,
102  const CQueue * queue,
103  bool verbose) const;
104 
105 };
106 
107 
109 
110 #endif /* NETSCHEDULE_SCOPE__HPP */
111 
CMutex –.
Definition: ncbimtx.hpp:749
unsigned int CheckRemoveCandidates(void)
Definition: ns_scope.cpp:292
TNSBitVector GetAllJobsInScopes(void) const
Definition: ns_scope.cpp:86
deque< string > GetScopeNames(void) const
Definition: ns_scope.cpp:241
void Clear(void)
Definition: ns_scope.cpp:233
void AddJobs(const string &scope, unsigned int first_job_id, unsigned int count)
Definition: ns_scope.cpp:117
string x_PrintOne(const string &scope_name, const TNSBitVector &jobs, const CQueue *queue, bool verbose) const
Definition: ns_scope.cpp:201
string Print(const CQueue *queue, size_t batch_size, bool verbose) const
Definition: ns_scope.cpp:156
bool CanAccept(const string &scope, size_t max_records) const
Definition: ns_scope.cpp:60
TNSBitVector GetJobs(const string &scope) const
Definition: ns_scope.cpp:74
string x_PrintSelected(const deque< string > &batch, const CQueue *queue, bool verbose) const
Definition: ns_scope.cpp:181
unsigned int CollectGarbage(unsigned int max_to_del)
Definition: ns_scope.cpp:269
map< string, TNSBitVector > TScopeToJobsMap
Definition: ns_scope.hpp:88
TNSBitVector m_AllScopedJobs
Definition: ns_scope.hpp:94
string GetJobScope(unsigned int job_id) const
Definition: ns_scope.cpp:254
size_t size(void) const
Definition: ns_scope.cpp:53
void RemoveJob(unsigned int job_id)
Definition: ns_scope.cpp:139
TScopeToJobsMap m_ScopeToJobs
Definition: ns_scope.hpp:91
void AddJob(const string &scope, unsigned int job_id)
Definition: ns_scope.cpp:93
Bitvector Bit-vector container with runtime compression of bits.
Definition: bm.h:115
Definition: map.hpp:338
string
Definition: cgiapp.hpp:687
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Multi-threading – mutexes; rw-locks; semaphore.
const string kNoScopeOnly
Definition: ns_scope.hpp:55
true_type verbose
Definition: processing.cpp:890
Modified on Sat Apr 20 12:19:19 2024 by modify_doxy.py rev. 669887