aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/JackDriver.cpp1
-rw-r--r--src/engine/Slave.hpp27
2 files changed, 13 insertions, 15 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index 0b25acc..1c90509 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -436,7 +436,6 @@ JackDriver::start_record(bool step)
case PlayState::PLAYING:
_recorder = SPtr<Recorder>(
new Recorder(_forge, 1024, _beats_unit, q, step));
- _recorder->start();
_record_dur = 0;
break;
case PlayState::RECORDING:
diff --git a/src/engine/Slave.hpp b/src/engine/Slave.hpp
index 55701a7..74ec06b 100644
--- a/src/engine/Slave.hpp
+++ b/src/engine/Slave.hpp
@@ -17,8 +17,9 @@
#ifndef MACHINA_SLAVE_HPP
#define MACHINA_SLAVE_HPP
+#include <thread>
+
#include "raul/Semaphore.hpp"
-#include "raul/Thread.hpp"
namespace machina {
@@ -27,19 +28,19 @@ namespace machina {
* Use this to perform some task in a separate thread you want to 'drive'
* from a realtime (or otherwise) thread.
*/
-class Slave : public Raul::Thread
+class Slave
{
public:
- Slave() : _whip(0) {}
- ~Slave() {
- _exit_flag = true;
- _whip.post();
- }
+ Slave()
+ : _whip(0)
+ , _exit_flag(false)
+ , _thread(&Slave::_run, this)
+ {}
- virtual void join() {
+ virtual ~Slave() {
_exit_flag = true;
_whip.post();
- Thread::join();
+ _thread.join();
}
/** Tell the slave to do whatever work it does. Realtime safe. */
@@ -58,15 +59,13 @@ protected:
private:
inline void _run() {
- while (true) {
- _whip.wait();
- if (_exit_flag) {
- break;
- }
+ while (_whip.wait() && !_exit_flag) {
_whipped();
}
}
+ bool _exit_flag;
+ std::thread _thread;
};
} // namespace machina