Skip to content

feat: RAII handles Peer & PacketPtr (#16)#33

Merged
Segfaultd merged 6 commits into
masterfrom
feat/raii-peer-packetptr-16
Jun 15, 2026
Merged

feat: RAII handles Peer & PacketPtr (#16)#33
Segfaultd merged 6 commits into
masterfrom
feat/raii-peer-packetptr-16

Conversation

@Segfaultd

Copy link
Copy Markdown
Member

Summary

Adds RAII wrappers around the two core MafiaNet lifetimes — wrap, don't remove the raw API (purely additive). Implements the keystone of issue #16.

  • MafiaNet::PacketPtr — owns a Packet* + its owning RakPeerInterface*; calls DeallocatePacket() in its destructor. Movable, non-copyable, exception-safe (null-out on move; move-assign releases the held packet first + self-assignment guard). Exposes operator->/operator*/get()/explicit operator bool, and an ID_TIMESTAMP-aware id() (consolidates the sample GetPacketIdentifier helper; hardened against truncated-timestamp OOB reads in release builds).
  • MafiaNet::Peer — owns the RakPeerInterface* (GetInstance()/DestroyInstance()); movable, non-copyable. Exposes operator->/get()/explicit operator bool and PacketPtr receive().
  • Compile-time static_assert trait checks pin the movable + non-copyable contract.
  • Exported from the mafianet.h umbrella.
  • Chat Example Client rewritten to demonstrate the wrappers (drops manual GetInstance/DestroyInstance/DeallocatePacket and the copied GetPacketIdentifier helper).

Naming note

The issue proposed Peer.h, but a legacy mafianet/peer.h (the RakPeer class header) already exists and collides case-insensitively on macOS/Windows. The new header is therefore PeerHandle.h; the public class names Peer/PacketPtr are unchanged.

Test Plan

Closes #16

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Segfaultd, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 9 minutes and 42 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6fe6b6b4-7fa6-4513-aa00-5801faf4c438

📥 Commits

Reviewing files that changed from the base of the PR and between 3714c07 and a8dadf7.

📒 Files selected for processing (9)
  • Samples/ChatExample/Client/Chat Example Client.cpp
  • Samples/Tests/IncludeAllTests.h
  • Samples/Tests/PeerHandleTest.cpp
  • Samples/Tests/PeerHandleTest.h
  • Samples/Tests/Tests.cpp
  • Source/CMakeLists.txt
  • Source/include/mafianet/PeerHandle.h
  • Source/include/mafianet/mafianet.h
  • Source/src/PeerHandle.cpp
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/raii-peer-packetptr-16

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Segfaultd

Copy link
Copy Markdown
Member Author

@coderabbitai review you lazy piece of rabbit

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

@Segfaultd Sure, hopping right on it! 🐇

(。•́︿•̀。) Sorry for the delay — reviewing now!

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Segfaultd Segfaultd merged commit efe2851 into master Jun 15, 2026
4 checks passed
@Segfaultd Segfaultd deleted the feat/raii-peer-packetptr-16 branch June 15, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DX L1] RAII handles: Peer and PacketPtr (keystone)

1 participant