C++ conversion (#80)

Converted project to C++
This commit is contained in:
Ken Van Hoeylandt
2024-11-22 20:26:08 +01:00
committed by GitHub
parent 6d80144e12
commit 85e26636a3
488 changed files with 6017 additions and 39466 deletions
+35
View File
@@ -0,0 +1,35 @@
/**
* @file Dispatcher.h
*
* Dispatcher is a thread-safe code execution queue.
*/
#pragma once
#include "MessageQueue.h"
#include "Mutex.h"
namespace tt {
typedef void (*Callback)(void* data);
class Dispatcher {
private:
typedef struct {
Callback callback;
void* context;
} DispatcherMessage;
MessageQueue queue;
Mutex mutex;
DispatcherMessage buffer; // Buffer for consuming a message
public:
explicit Dispatcher(size_t queueLimit = 8);
~Dispatcher();
void dispatch(Callback callback, void* context);
bool consume(uint32_t timeout_ticks);
};
} // namespace