Files
Jungfraujoch/image_pusher/ZMQStream2PusherSocket.h
leonarski_f 8280fde0a2
Some checks failed
Build Packages / build:rpm (rocky8_nocuda) (push) Has been cancelled
Build Packages / build:rpm (rocky9_nocuda) (push) Has been cancelled
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Has been cancelled
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Has been cancelled
Build Packages / build:rpm (rocky8_sls9) (push) Has been cancelled
Build Packages / build:rpm (rocky9_sls9) (push) Has been cancelled
Build Packages / build:rpm (rocky8) (push) Has been cancelled
Build Packages / build:rpm (rocky9) (push) Has been cancelled
Build Packages / build:rpm (ubuntu2204) (push) Has been cancelled
Build Packages / build:rpm (ubuntu2404) (push) Has been cancelled
Build Packages / Generate python client (push) Has been cancelled
Build Packages / Build documentation (push) Has been cancelled
Build Packages / Unit tests (push) Has been cancelled
Build Packages / Create release (push) Has been cancelled
ImagePusher: Make ZMQStream2Pusher similar to HDF5FilePusher, with a message queue and sending thread
2026-02-28 23:25:32 +01:00

42 lines
1.2 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#ifndef JFJOCH_ZMQSTREAM2PUSHERSOCKET_H
#define JFJOCH_ZMQSTREAM2PUSHERSOCKET_H
#include <mutex>
#include <future>
#include <string>
#include <optional>
#include "ImagePusher.h"
#include "../common/ZMQWrappers.h"
#include "../common/ThreadSafeFIFO.h"
#include "../common/ZeroCopyReturnValue.h"
class ZMQStream2PusherSocket {
std::mutex m;
std::atomic<bool> active = false;
std::future<void> send_future;
ThreadSafeFIFO<ImagePusherQueueElement> queue;
ZMQSocket s;
void WriterThread();
public:
explicit ZMQStream2PusherSocket(const std::string& addr,
std::optional<int32_t> send_buffer_high_watermark,
std::optional<int32_t> send_buffer_size);
std::string GetEndpointName();
// Strictly serial, as order of these is important
bool Send(const uint8_t *data, size_t size);
void StartWriterThread();
void StopWriterThread();
// Thread-safe
void SendImage(ZeroCopyReturnValue &z);
};
#endif //JFJOCH_ZMQSTREAM2PUSHERSOCKET_H