载入中...
搜索中...
未找到
PixelWorldTransport.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Result.h"
8
9#include <cstdint>
10#include <map>
11#include <memory>
12#include <vector>
13
15
18 std::uint32_t maximumInFlightTransfers = 8;
19 std::uint32_t maximumChunksPerPart = 1;
20 std::uint32_t maximumPartsPerTransfer = 8192;
21 std::uint32_t maximumBufferedTransfers = 16;
22};
23
26 std::uint64_t streamId = 0;
27 std::uint64_t transferId = 0;
28 std::uint32_t partIndex = 0;
29 std::uint32_t partCount = 0;
32
34 friend bool operator==(const PixelChunkTransferPart&, const PixelChunkTransferPart&) = default;
35};
36
39 std::uint64_t streamId = 0;
40 std::uint64_t acknowledgedThrough = 0;
41 std::uint64_t appliedRevision = 0;
42};
43
46 std::uint32_t transfersReleased = 0;
47 std::uint32_t tombstonesReleased = 0;
48 std::uint64_t acknowledgedThrough = 0;
49};
50
54 std::uint32_t transfersApplied = 0;
55 std::uint32_t partsBuffered = 0;
56 bool duplicate = false;
57};
58
67public:
69 [[nodiscard]] static eve::Result<ReliablePixelChunkSender> create(
70 std::uint64_t streamId, PixelChunkTransportConfig config = {});
71
76
78 [[nodiscard]] std::vector<PixelChunkTransferPart> pendingParts() const;
80 [[nodiscard]] eve::Result<PixelChunkAckReceipt> acknowledge(PixelChunkTransferAck ack);
82 [[nodiscard]] std::size_t inFlightTransferCount() const noexcept;
84 [[nodiscard]] std::size_t retainedTombstoneCount() const noexcept;
85
86private:
87 ReliablePixelChunkSender(std::uint64_t streamId, PixelChunkTransportConfig config);
88
89 std::uint64_t streamId_ = 0;
90 std::uint64_t nextTransferId_ = 1;
91 std::uint64_t acknowledgedThrough_ = 0;
92 std::uint64_t lastEnqueuedRevision_ = 0;
93 bool captured_ = false;
96 std::map<std::uint64_t, std::vector<PixelChunkTransferPart>> inFlight_;
97};
98
107public:
108 // Class-level dllexport instantiates every member; `buffered_` holds an
109 // Assembly with a vector<unique_ptr>, so the implicit copy assignment would be
110 // a hard C2280. Moves stay available (create() returns by value).
118 [[nodiscard]] static eve::Result<ReliablePixelChunkReceiver> create(
119 std::uint64_t streamId, PixelChunkTransportConfig config = {});
120
122 [[nodiscard]] eve::Result<PixelChunkReceiveReceipt> receive(
125 [[nodiscard]] std::uint64_t acknowledgedThrough() const noexcept { return expectedTransferId_ - 1; }
127 [[nodiscard]] std::size_t bufferedPartCount() const noexcept;
128
129private:
130 struct Assembly {
131 std::uint32_t partCount = 0;
132 std::vector<std::unique_ptr<PixelChunkTransferPart>> parts;
133 };
134
135 ReliablePixelChunkReceiver(std::uint64_t streamId, PixelChunkTransportConfig config);
136
137 std::uint64_t streamId_ = 0;
138 std::uint64_t expectedTransferId_ = 1;
139 PixelChunkTransportConfig config_{};
140 std::map<std::uint64_t, Assembly> buffered_;
141};
142
143} // namespace eve::pixelworld_streaming
std::vector< eve::artifact::PartView > parts
#define EVENGINE_API_PLATFORM
Definition Export.h:107
Move-only, checked operation results for the common layer.
const UnitySourceAsset & source
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Sparse, chunked, deterministic 2D falling-material world.
Definition PixelWorld.h:224
Stateful revision cursor that projects one PixelWorld interest region.
Ordered atomic receiver with duplicate suppression and bounded out-of-order buffering.
ReliablePixelChunkReceiver & operator=(const ReliablePixelChunkReceiver &)=delete
ReliablePixelChunkReceiver & operator=(ReliablePixelChunkReceiver &&)=default
Operator =.
ReliablePixelChunkReceiver(ReliablePixelChunkReceiver &&)=default
Reliable pixel chunk receiver.
ReliablePixelChunkReceiver(const ReliablePixelChunkReceiver &)=delete
std::uint64_t acknowledgedThrough() const noexcept
Last cumulatively applied transfer id.
Reliable sender retaining owning transfer parts and tombstones until application ACK.
Owning authoritative Chunk correction with source world metadata.
Definition PixelWorld.h:89
Inclusive finite rectangle expressed in Chunk coordinates.
Definition PixelWorld.h:104
Counters returned after accepting a cumulative ACK.
Receiver outcome after one possibly duplicate or out-of-order part.
Cumulative application ACK proving transfers were committed to replica authority.
One independently retransmittable part of an atomic Chunk transfer.
friend bool operator==(const PixelChunkTransferPart &, const PixelChunkTransferPart &)=default
Operator ==.
Bounded application-level reliability policy layered over any byte transport.