MySQL  8.0.19
Source Code Documentation
thread_resource_control.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2  This program is free software; you can redistribute it and/or modify
3  it under the terms of the GNU General Public License, version 2.0,
4  as published by the Free Software Foundation.
5 
6  This program is also distributed with certain software (including
7  but not limited to OpenSSL) that is licensed under separate terms,
8  as designated in a particular file or component or in included license
9  documentation. The authors of MySQL hereby grant you an additional
10  permission to link the program and your derivative works with the
11  separately licensed software that they have included with MySQL.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License, version 2.0, for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
21 
22 #ifndef RESOURCEGROUPS_THREAD_RESOURCE_CONTROL_H_
23 #define RESOURCEGROUPS_THREAD_RESOURCE_CONTROL_H_
24 
25 #include <vector>
26 
27 #include "my_thread_os_id.h"
29 
30 namespace resourcegroups {
31 
32 /**
33  Class that abstracts the resource control that can be applied
34  to threads. The resource controls include set of CPU IDS which
35  determine the CPUS the thread is allowed to run and the thread
36  priority.
37 */
38 
40  public:
41  /**
42  Default constructor
43  */
44 
46 
47  /**
48  Get priority associated with Thread resource control object.
49 
50  @return an int value indicating the thread priority.
51  */
52 
53  int priority() const { return m_priority; }
54 
55  /**
56  Set priority associated with Thread resource control object.
57  */
58 
60 
61  /**
62  Get const pointer of vector of CPU ID range.
63 
64  @return pointer to vector of CPU ID range.
65  */
66 
67  const std::vector<Range> &vcpu_vector() const { return m_vcpu_vector; }
68 
69  /**
70  Set the CPU ID range vector.
71  */
72 
73  void set_vcpu_vector(const std::vector<Range> &vcpu_vector) {
74  m_vcpu_vector.clear();
75  for (const auto &cpu_range : vcpu_vector)
76  m_vcpu_vector.emplace_back(cpu_range);
77  }
78 
79  /**
80  Apply the thread resource controls to the thread on
81  which this function is called.
82 
83  @return false if control application is successful else true
84  */
85 
86  bool apply_control();
87 
88  /**
89  Apply the thread resource controls to thread identified by
90  the thread os id.
91 
92  @param thread_os_id Thread OS ID.
93 
94  @return false if control application is successful else true
95  */
96 
97  bool apply_control(my_thread_os_id_t thread_os_id);
98 
99  /**
100  Validate the CPU ID Ranges and thread priority value associate with
101  the thread resource control object.
102 
103  @return false if validation is successful else true.
104  */
105 
106  bool validate(const Type &resource_group_type) const;
107 
108  private:
109  /**
110  Vector of CPU ID range.
111  */
112  std::vector<Range> m_vcpu_vector;
113 
114  /**
115  Thread priority value
116  */
118 };
119 } // namespace resourcegroups
120 #endif // RESOURCEGROUPS_THREAD_RESOURCE_CONTROL_H_
resourcegroups::Thread_resource_control::m_priority
int m_priority
Thread priority value.
Definition: thread_resource_control.h:117
my_thread_os_id_t
unsigned long long my_thread_os_id_t
Definition: my_thread_os_id.h:47
my_thread_os_id.h
resourcegroups::Thread_resource_control::validate
bool validate(const Type &resource_group_type) const
Validate the CPU ID Ranges and thread priority value associate with the thread resource control objec...
Definition: thread_resource_control.cc:33
resourcegroups::Thread_resource_control::vcpu_vector
const std::vector< Range > & vcpu_vector() const
Get const pointer of vector of CPU ID range.
Definition: thread_resource_control.h:67
resourcegroups::Thread_resource_control::m_vcpu_vector
std::vector< Range > m_vcpu_vector
Vector of CPU ID range.
Definition: thread_resource_control.h:112
resource_group_basic_types.h
resourcegroups::Type
Type
Definition: resource_group_basic_types.h:32
resourcegroups::Thread_resource_control::Thread_resource_control
Thread_resource_control()
Default constructor.
Definition: thread_resource_control.h:45
resourcegroups::Thread_resource_control::apply_control
bool apply_control()
Apply the thread resource controls to the thread on which this function is called.
Definition: thread_resource_control.cc:74
resourcegroups::Thread_resource_control
Class that abstracts the resource control that can be applied to threads.
Definition: thread_resource_control.h:39
resourcegroups::Thread_resource_control::priority
int priority() const
Get priority associated with Thread resource control object.
Definition: thread_resource_control.h:53
resourcegroups
Definition: dd_resource_group.h:28
resourcegroups::Thread_resource_control::set_priority
void set_priority(int priority)
Set priority associated with Thread resource control object.
Definition: thread_resource_control.h:59
resourcegroups::Thread_resource_control::set_vcpu_vector
void set_vcpu_vector(const std::vector< Range > &vcpu_vector)
Set the CPU ID range vector.
Definition: thread_resource_control.h:73