<commit_before>#ifndef SLICPLUSPLUS_LLSTREAM_HPP_
#define SLICPLUSPLUS_LLSTREAM_HPP_

#include <stdexcept>
#include <MaxSLiCInterface.h>
#include "internal/MemAlignedBuffer.hpp"

SLIC_BEGIN_NAMESPACE

class Engine;

class LowLatencyStream {
protected:
	size_t numSlots;
	MemAlignedBuffer buf;
	std::unique_ptr<max_llstream_t, decltype(max_llstream_release)*> ll;

	LowLatencyStream() : ll(nullptr, max_llstream_release) {}

	LowLatencyStream(max_engine_t* engine, const std::string& name, size_t numSlots, size_t slotSize)
	: numSlots(numSlots),
	  buf(numSlots*slotSize),
	  ll(max_llstream_setup(engine, name.c_str(), numSlots, slotSize, buf), max_llstream_release)
	{
		if (!ll) throw std::runtime_error("Failed to instantiate llstream");
	}

public:
	static constexpr size_t MAX_SLOTS = 512;

	size_t getNumSlots() const noexcept {
		return numSlots;
	}

	static size_t nextPowerOfTwo(size_t value) {
		size_t res = 1;
		while (res < value) res <<= 1;
		return res;
	}
};

class LowLatencyInputStream : public LowLatencyStream {
	friend class Engine;

	LowLatencyInputStream(max_engine_t* engine, const std::string& name, size_t numSlots, size_t slotSize)
	 : LowLatencyStream(engine, name, numSlots, slotSize) {}

public:
	LowLatencyInputStream() = default;

	ssize_t acquire(size_t numSlots, void** slots) {
		return max_llstream_write_acquire(ll.get(), numSlots, slots);
	}

	void write(size_t numSlots) {
		max_llstream_write(ll.get(), numSlots);
	}
};

class LowLatencyOutputStream : public LowLatencyStream {<commit_msg>Add getSlotSize() method.<commit_after>#ifndef SLICPLUSPLUS_LLSTREAM_HPP_
#define SLICPLUSPLUS_LLSTREAM_HPP_

#include <stdexcept>
#include <MaxSLiCInterface.h>
#include "internal/MemAlignedBuffer.hpp"

SLIC_BEGIN_NAMESPACE

class Engine;

class LowLatencyStream {
protected:
	size_t numSlots;
	size_t slotSize;
	MemAlignedBuffer buf;
	std::unique_ptr<max_llstream_t, decltype(max_llstream_release)*> ll;

	LowLatencyStream() : ll(nullptr, max_llstream_release) {}

	LowLatencyStream(max_engine_t* engine, const std::string& name, size_t numSlots, size_t slotSize)
	: numSlots(numSlots), slotSize(slotSize), buf(numSlots*slotSize),
	  ll(max_llstream_setup(engine, name.c_str(), numSlots, slotSize, buf), max_llstream_release)
	{
		if (!ll) throw std::runtime_error("Failed to instantiate llstream");
	}

public:
	static constexpr size_t MAX_SLOTS = 512;

	size_t getNumSlots() const noexcept {
		return numSlots;
	}

	size_t getSlotSize() const noexcept {
		return slotSize;
	}

	static size_t nextPowerOfTwo(size_t value) {
		size_t res = 1;
		while (res < value) res <<= 1;
		return res;
	}
};

class LowLatencyInputStream : public LowLatencyStream {
	friend class Engine;

	LowLatencyInputStream(max_engine_t* engine, const std::string& name, size_t numSlots, size_t slotSize)
	 : LowLatencyStream(engine, name, numSlots, slotSize) {}

public:
	LowLatencyInputStream() = default;

	ssize_t acquire(size_t numSlots, void** slots) {
		return max_llstream_write_acquire(ll.get(), numSlots, slots);
	}

	void write(size_t numSlots) {
		max_llstream_write(ll.get(), numSlots);
	}
};

class LowLatencyOutputStream : public LowLatencyStream {
{'fraction_non_alphanumeric': 0.10413379615020511, 'fraction_numerical': 0.003155569580309246, 'mean_word_length': 6.372093023255814, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3279645', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1151, 'n_words': 245}