29 lines
733 B
C++
29 lines
733 B
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#ifndef JUNGFRAUJOCH_ZEROCOPYRETURNVALUE_H
|
|
#define JUNGFRAUJOCH_ZEROCOPYRETURNVALUE_H
|
|
|
|
#include "ThreadSafeFIFO.h"
|
|
|
|
class ZeroCopyReturnValue {
|
|
void *ptr;
|
|
uint32_t handle;
|
|
ThreadSafeFIFO<uint32_t> *fifo;
|
|
public:
|
|
ZeroCopyReturnValue(void *in_ptr,
|
|
ThreadSafeFIFO<uint32_t> &in_fifo,
|
|
uint32_t in_handle) :
|
|
ptr(in_ptr), fifo(&in_fifo), handle(in_handle) {}
|
|
|
|
void *get_ptr() const {
|
|
return ptr;
|
|
}
|
|
|
|
void release() const {
|
|
fifo->PutBlocking(handle);
|
|
}
|
|
};
|
|
|
|
#endif //JUNGFRAUJOCH_ZEROCOPYRETURNVALUE_H
|