Queue.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef CORE_QUEUE_H
  2. #define CORE_QUEUE_H
  3. #include "core/Types.h"
  4. struct CoreQueueT {
  5. size_t writeIndex;
  6. size_t readIndex;
  7. size_t length;
  8. size_t capacity;
  9. size_t dataSize;
  10. void* data;
  11. };
  12. typedef struct CoreQueueT CoreQueue;
  13. void coreInitQueue(CoreQueue* r, size_t capacity, size_t dataSize);
  14. void coreDestroyQueue(CoreQueue* r);
  15. void corePushQueueData(CoreQueue* r, const void* data);
  16. #define corePushQueueType(l, type, ...) \
  17. corePushQueueData(l, &(type){__VA_ARGS__})
  18. void* coreGetQueueIndex(const CoreQueue* r, size_t index);
  19. #define coreGetTypedQueueIndex(r, index, type) \
  20. (*(type*)coreGetQueueIndex(r, index))
  21. void coreClearQueue(CoreQueue* r);
  22. void corePopQueueData(CoreQueue* r);
  23. #ifdef IMPORT_CORE
  24. #define Queue CoreQueue
  25. #define initQueue coreInitQueue
  26. #define destroyQueue coreDestroyQueue
  27. #define pushQueueData corePushQueueData
  28. #define pushQueueType corePushQueueType
  29. #define getQueueIndex coreGetQueueIndex
  30. #define getTypedQueueIndex coreGetTypedQueueIndex
  31. #define clearQueue coreClearQueue
  32. #define popQueueData corePopQueueData
  33. #endif
  34. #endif