1 #ifndef _QUEUE_SPOT_HOLDER
2 #define _QUEUE_SPOT_HOLDER 1
4 // A RAII class to hold a shared resource, in our case an (unordered!) spot in a queue,
5 // for as long as a frame is under computation.
9 virtual ~QueueInterface() {}
10 virtual void take_queue_spot() = 0;
11 virtual void release_queue_spot() = 0;
14 class QueueSpotHolder {
19 explicit QueueSpotHolder(QueueInterface *queue)
22 queue->take_queue_spot();
25 QueueSpotHolder(QueueSpotHolder &&other)
28 other.queue = nullptr;
31 QueueSpotHolder &operator=(QueueSpotHolder &&other)
34 other.queue = nullptr;
40 if (queue != nullptr) {
41 queue->release_queue_spot();
46 QueueSpotHolder(QueueSpotHolder &) = delete;
47 QueueSpotHolder &operator=(QueueSpotHolder &) = delete;
50 QueueInterface *queue;
53 #endif // !defined(_QUEUE_SPOT_HOLDER)