/************************************************************************* * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. * * See LICENSE.txt for license information ************************************************************************/ #ifndef QUEUE_H #define QUEUE_H template struct profilerQueue { T *head, *tail; }; template inline void profilerQueueConstruct(profilerQueue *me) { me->head = nullptr; me->tail = nullptr; } template inline bool profilerQueueEmpty(profilerQueue *me) { return me->head == nullptr; } template inline T* profilerQueueHead(profilerQueue *me) { return me->head; } template inline T* profilerQueueTail(profilerQueue *me) { return me->tail; } template inline void profilerQueueEnqueue(profilerQueue *me, T *x) { x->*next = nullptr; (me->head ? me->tail->*next : me->head) = x; me->tail = x; } template inline T* profilerQueueDequeue(profilerQueue *me) { T *ans = me->head; me->head = ans->*next; if (me->head == nullptr) me->tail = nullptr; return ans; } #endif