OSSIA
Open Scenario System for Interactive Application
thread.hpp
1 #pragma once
2 #include <ossia/detail/config.hpp>
3 
4 #include <ossia/detail/flat_map.hpp>
5 
6 #include <string>
7 #include <thread>
8 
9 namespace ossia
10 {
11 OSSIA_EXPORT
12 void set_thread_realtime(std::thread& t, int prio = 99, bool algo_fifo = true);
13 OSSIA_EXPORT
14 void set_thread_name(std::thread& t, std::string_view name);
15 OSSIA_EXPORT
16 void set_thread_name(std::string_view name);
17 OSSIA_EXPORT
18 void set_thread_pinned(int cpu);
19 
20 enum class thread_type : unsigned char
21 {
22  Net = 'N',
23  Midi = 'M',
24  Gpu = 'G',
25  GpuTask = 'g',
26  Audio = 'A',
27  AudioTask = 'a',
28  Ui = 'U',
29  UiTask = 'u'
30 };
31 
32 struct thread_spec
33 {
34  int num_threads{};
35  int spin_interval{};
36 };
37 
38 using thread_specs = ossia::flat_map<thread_type, thread_spec>;
39 
40 OSSIA_EXPORT
41 const thread_specs& get_thread_specs() noexcept;
42 
43 // Schedule e.g. the third net thread on the appropriate CPU
44 OSSIA_EXPORT
45 void set_thread_pinned(thread_type kind, int thread_index);
46 
47 OSSIA_EXPORT
48 std::string get_exe_path();
49 
50 OSSIA_EXPORT
51 std::string get_module_path();
52 
53 OSSIA_EXPORT
54 int get_pid();
55 }
Definition: git_info.h:7