OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
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
9namespace ossia
10{
11OSSIA_EXPORT
12void set_thread_realtime(std::thread& t, int prio = 99, bool algo_fifo = true);
13OSSIA_EXPORT
14void set_thread_name(std::thread& t, std::string_view name);
15OSSIA_EXPORT
16void set_thread_name(std::string_view name);
17OSSIA_EXPORT
18void set_thread_pinned(int cpu);
19
20enum 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
32struct thread_spec
33{
34 int num_threads{};
35 int spin_interval{};
36};
37
38using thread_specs = ossia::flat_map<thread_type, thread_spec>;
39
40OSSIA_EXPORT
41const thread_specs& get_thread_specs() noexcept;
42
43OSSIA_EXPORT
44thread_type get_current_thread_type();
45
46// Schedule e.g. the third net thread on the appropriate CPU
47OSSIA_EXPORT
48void set_thread_pinned(thread_type kind, int thread_index);
49
50OSSIA_EXPORT
51void ensure_current_thread(thread_type kind);
52
53#if defined(NDEBUG)
54#define OSSIA_ENSURE_CURRENT_THREAD(a) \
55 do \
56 { \
57 } while(0)
58#else
59#define OSSIA_ENSURE_CURRENT_THREAD(a) ::ossia::ensure_current_thread(a)
60#endif
61
62OSSIA_EXPORT
63std::string get_exe_path();
64
65OSSIA_EXPORT
66std::string get_exe_folder();
67
68OSSIA_EXPORT
69std::string get_module_path();
70
71OSSIA_EXPORT
72int get_pid();
73}
Definition git_info.h:7