OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
direct_policy.hpp
1#pragma once
2#include <ossia/detail/config.hpp>
3#if !defined(OSSIA_FREESTANDING)
4#include <ossia/dataflow/execution/execution_policy.hpp>
5#include <ossia/detail/lockfree_queue.hpp>
6#include <ossia/network/base/bundle.hpp>
7
8#include <blockingconcurrentqueue.h>
9
10#include <thread>
11
12namespace ossia
13{
14// If we do not use the local state, we can use this policy instead
15struct direct_execution_state_policy : execution_state_policy
16{
17 direct_execution_state_policy();
18 ~direct_execution_state_policy();
19
20 void commit() override;
21
22 void clear_local_state() override;
23
24 bool find_and_copy(net::parameter_base& addr, inlet& in) override;
25 bool in_local_scope(net::parameter_base& other) const override;
26
27 void insert(ossia::net::parameter_base& dest, const ossia::value_port& v) override;
28 void insert(ossia::audio_parameter& dest, const audio_port& v) override;
29 void insert(ossia::net::midi::midi_parameter& dest, const midi_port& v) override;
30
31 void process_messages();
32 void process_midi();
33
34 struct T : moodycamel::ConcurrentQueueDefaultTraits
35 {
36 static constexpr std::size_t CQ_BLOCK_SIZE = 2048;
37 };
38
39 moodycamel::BlockingConcurrentQueue<ossia::bundle_element, T> m_messagesToApply;
40
41 static constexpr int max_threads = 16;
42 struct net_thread
43 {
44 std::thread thread;
45 } m_threads[max_threads];
46
47 std::thread m_midiThread;
48
49 std::atomic_bool m_startFlag{};
50 std::atomic_bool m_stopFlag{};
51
52 struct audio_msg
53 {
54 const ossia::audio_port* src{};
55 ossia::audio_parameter* dst{};
56 };
57 ossia::mpmc_queue<audio_msg> m_audioQueue;
58
59 struct midi_msg
60 {
61 const ossia::midi_port* src{};
62 ossia::net::midi::midi_parameter* dst{};
63 };
64 ossia::mpmc_queue<midi_msg> m_midiQueue;
65};
66}
67#endif
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
Definition git_info.h:7