xref: /oneTBB/src/tbb/tcm_adaptor.h (revision 71e1bb8e)
1 /*
2     Copyright (c) 2023 Intel Corporation
3 
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7 
8         http://www.apache.org/licenses/LICENSE-2.0
9 
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15 */
16 
17 #ifndef _TBB_tcm_adaptor_H
18 #define _TBB_tcm_adaptor_H
19 
20 #include "scheduler_common.h"
21 
22 #include "permit_manager.h"
23 #include "pm_client.h"
24 
25 namespace tbb {
26 namespace detail {
27 namespace r1 {
28 
29 struct tcm_adaptor_impl;
30 
31 //------------------------------------------------------------------------
32 // Class tcm_adaptor
33 //------------------------------------------------------------------------
34 
35 class tcm_adaptor : public permit_manager {
36 public:
37     tcm_adaptor();
38     ~tcm_adaptor();
39 
40     pm_client* create_client(arena& a) override;
41     void register_client(pm_client* client, d1::constraints& constraints) override;
42     void unregister_and_destroy_client(pm_client& c) override;
43 
44     void set_active_num_workers(int soft_limit) override;
45 
46     void adjust_demand(pm_client& c, int mandatory_delta, int workers_delta)  override;
47 
48     bool is_connected();
49 
50     static void initialize();
51     static bool is_initialized();
52     static void print_version();
53 private:
54     cache_aligned_unique_ptr<tcm_adaptor_impl> my_impl;
55 
56     friend class tcm_client;
57 }; // class tcm_adaptor
58 
59 } // namespace r1
60 } // namespace detail
61 } // namespace tbb
62 
63 #endif /* _TBB_tcm_adaptor_H */
64