You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
concurrentqueue/c_api/concurrentqueue.cpp

40 lines
911 B
C++

#include "concurrentqueue.h"
#include "../concurrentqueue.h"
typedef moodycamel::ConcurrentQueue<void*> MoodycamelCQType, *MoodycamelCQPtr;
extern "C" {
int moodycamel_cq_create(MoodycamelCQHandle* handle)
{
MoodycamelCQPtr retval = new MoodycamelCQType;
if (retval == nullptr) {
return 0;
}
*handle = retval;
return 1;
}
int moodycamel_cq_destroy(MoodycamelCQHandle handle)
{
delete reinterpret_cast<MoodycamelCQPtr>(handle);
return 1;
}
int moodycamel_cq_enqueue(MoodycamelCQHandle handle, MoodycamelValue value)
{
return reinterpret_cast<MoodycamelCQPtr>(handle)->enqueue(value) ? 1 : 0;
}
int moodycamel_cq_try_dequeue(MoodycamelCQHandle handle, MoodycamelValue* value)
{
return reinterpret_cast<MoodycamelCQPtr>(handle)->try_dequeue(*value) ? 1 : 0;
}
size_t moodycamel_cq_size_approx(MoodycamelCQHandle handle)
{
return reinterpret_cast<MoodycamelCQPtr>(handle)->size_approx();
}
}