atomic
This commit is contained in:
+29
-2
@@ -1,24 +1,51 @@
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
#include "../include/synth.hpp"
|
||||
#include "../include/audio_engine.hpp"
|
||||
#include "../include/spsc_queue.hpp"
|
||||
#include "../include/command.hpp"
|
||||
|
||||
void producer(SpscQueue& queue, std::atomic<bool>& producer_done){
|
||||
/*
|
||||
* формирует последовательность команд;
|
||||
записывает их через queue.push();
|
||||
повторяет попытку, если очередь заполнена;
|
||||
после успешной отправки последней команды устанавливает producer_done = true.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void consumer(SpscQueue& queue, std::atomic<bool>& producer_done){
|
||||
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "110.гц\n";
|
||||
std::string a = "";
|
||||
Synth synth;
|
||||
SpscQueue queue;
|
||||
|
||||
std::atomic<bool> producer_done;
|
||||
|
||||
// std::thread producer();
|
||||
// std::thread consumer();
|
||||
|
||||
synth.set_frequency(110);
|
||||
synth.set_amplitude(0.5);
|
||||
|
||||
|
||||
|
||||
try{
|
||||
AudioEngine audio_engine(synth);
|
||||
audio_engine.start();
|
||||
while (true){
|
||||
std::cout << std::boolalpha
|
||||
<< "Lock-free: " << std::atomic<Command>{}.is_lock_free()
|
||||
<< '\n';
|
||||
std::cin >> a;
|
||||
if (a == "start"){
|
||||
synth.note_on();
|
||||
|
||||
Reference in New Issue
Block a user