Files
EchoionCore/include/echoion/core/QueueManager.hpp
T
faumarayandClaude Opus 4.8 1efdbe0771 Extract QueueManager from MusicManager
Move the playback queue + shuffle state (the queue vector, shuffled-index
list, shuffle cursor, next-queue-id counter, and RNG) into a QueueManager
class. To preserve the real-time playback loop's exact behavior, the design
is deliberately minimal: QueueManager is a non-thread-safe data holder that
exposes its containers by reference, and MusicManager keeps its single
playback mutex_/cv_ and drives QueueManager under it. Every former queue_/
shuffledIndices_/shuffleIndex_/nextQueueId_/rng_ site is a 1:1 rename to the
accessor with identical semantics — no logic, locking, or ordering change.

Build green. Runtime behavior in the live playback loop is unverified here
(no audio/TeamSpeak); this is an isolated, revertible commit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 01:25:07 +03:00

54 lines
1.3 KiB
C++

#pragma once
#include <TrackTypes.hpp>
#include <cstddef>
#include <cstdint>
#include <random>
#include <vector>
namespace Echoion::Core
{
// Owns the playback queue and its shuffle state. NOT thread-safe by
// design: the owning MusicManager serializes every access under its
// playback mutex_, so the single-lock model of the real-time loop is
// preserved. The containers are exposed by reference so the playback loop
// keeps operating on them with identical semantics.
class QueueManager
{
public:
using Entry = Api::QueueEntry;
[[nodiscard]] std::vector<Entry>& entries() noexcept
{
return entries_;
}
[[nodiscard]] const std::vector<Entry>& entries() const noexcept
{
return entries_;
}
[[nodiscard]] std::vector<std::size_t>& shuffledIndices() noexcept
{
return shuffledIndices_;
}
[[nodiscard]] std::size_t& shuffleIndex() noexcept
{
return shuffleIndex_;
}
[[nodiscard]] std::uint64_t& nextQueueId() noexcept
{
return nextQueueId_;
}
[[nodiscard]] std::mt19937& rng() noexcept { return rng_; }
private:
std::vector<Entry> entries_;
std::vector<std::size_t> shuffledIndices_;
std::size_t shuffleIndex_ = 0;
std::uint64_t nextQueueId_ = 1;
std::mt19937 rng_{std::random_device{}()};
};
} // namespace Echoion::Core