]> git.sesse.net Git - nageru/blob - ref_counted_frame.h
Switch to getting bmusb from a submodule.
[nageru] / ref_counted_frame.h
1 #ifndef _REF_COUNTED_FRAME_H
2 #define _REF_COUNTED_FRAME_H 1
3
4 // A wrapper around FrameAllocator::Frame that is automatically refcounted;
5 // when the refcount goes to zero, the frame is given back to the allocator.
6 //
7 // Note that the important point isn't really the pointer to the Frame itself,
8 // it's the resources it's representing that need to go back to the allocator.
9
10 #include "bmusb/bmusb.h"
11
12 void release_refcounted_frame(FrameAllocator::Frame *frame);
13
14 typedef std::shared_ptr<FrameAllocator::Frame> RefCountedFrameBase;
15
16 class RefCountedFrame : public RefCountedFrameBase {
17 public:
18         RefCountedFrame() {}
19
20         RefCountedFrame(const FrameAllocator::Frame &frame)
21                 : RefCountedFrameBase(new FrameAllocator::Frame(frame), release_refcounted_frame) {}
22 };
23
24 #endif  // !defined(_REF_COUNTED_FRAME_H)