xref: /oneTBB/src/tbb/thread_dispatcher_client.h (revision c4568449)
1 /*
2     Copyright (c) 2022-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_thread_dispatcher_client_H
18 #define _TBB_thread_dispatcher_client_H
19 
20 #include "oneapi/tbb/detail/_intrusive_list_node.h"
21 #include "arena.h"
22 
23 namespace tbb {
24 namespace detail {
25 namespace r1 {
26 
27 class thread_dispatcher_client : public d1::intrusive_list_node /* Need for list in thread pool */ {
28 public:
thread_dispatcher_client(arena & a,std::uint64_t aba_epoch)29     thread_dispatcher_client(arena& a, std::uint64_t aba_epoch) : my_arena(a), my_aba_epoch(aba_epoch) {}
30 
31     // Interface of communication with thread pool
try_join()32     bool try_join() {
33         return my_arena.try_join();
34     }
process(thread_data & td)35     void process(thread_data& td) {
36         my_arena.process(td);
37     }
38 
priority_level()39     unsigned priority_level() {
40         return my_arena.priority_level();
41     }
42 
get_aba_epoch()43     std::uint64_t get_aba_epoch() {
44         return my_aba_epoch;
45     }
46 
references()47     unsigned references() {
48         return my_arena.references();
49     }
50 
has_request()51     bool has_request() {
52         return my_arena.has_request();
53     }
54 
55 private:
56     arena& my_arena;
57     std::uint64_t my_aba_epoch;
58 };
59 
60 } // namespace r1
61 } // namespace detail
62 } // namespace tbb
63 
64 #endif // _TBB_thread_dispatcher_client_H
65