百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

NetStack

> 数据库
开源

用于为多人游戏创建并发网络系统的轻量级工具集

325 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于为多人游戏创建并发网络系统的轻量级工具集

Lightweight toolset for creating concurrent networking systems for multiplayer games.

NetStack is self-contained and has no dependencies.

Modules:

  • Buffers
    • Thread-safe array pool
  • Quantization
    • Half precision algorithm
    • Bounded range algorithm
    • Smallest three algorithm
  • Serialization
    • Lightweight and straightforward
    • Fast processing
    • Span support
    • Fluent builder support
    • Compact bit-packing
      • ZigZag encoding
      • Variable-length encoding
  • Threading
    • Array queue
      • Single-producer single-consumer first-in-first-out non-blocking queue
    • Concurrent buffer
      • Multi-producer multi-consumer first-in-first-out non-blocking queue
    • Concurrent pool
      • Self-stabilizing semi-lockless circular buffer
  • Unsafe
    • Fast memory copying

Building

By default, all scripts are compiled for .NET Framework 3.5. Define NET_4_6 directive to build the assembly for .NET Framework 4.6 or higher. Define NET_STANDARD_2_0 to build the assembly for .NET Core 2.1 or higher.

Define NETSTACK_SPAN to enable support for Span.

Define NETSTACK_BUFFERS_LOG to enable buffers logging.

Usage

Thread-safe buffers pool
…
Concurrent objects buffer
csharp
// Create a new concurrent buffer limited to 8192 cells
ConcurrentBuffer conveyor = new ConcurrentBuffer(8192);

// Enqueue an object
conveyor.Enqueue(message);

// Dequeue object
MessageObject message = (MessageObject)conveyor.Dequeue();
Quantize float
csharp
ushort quantizedSpeed = HalfPrecision.Quantize(speed);

float speed = HalfPrecision.Dequantize(quantizedSpeed);
Quantize vector
…
Quantize quaternion
csharp
// Quantize rotation data ready for compact bit-packing 
QuantizedQuaternion quantizedRotation = SmallestThree.Quantize(rotation);

// Read quantized data
Console.WriteLine("Quantized rotation - M: " + quantizedRotation.m + ", A:" + quantizedRotation.a + ", B:" + quantizedRotation.b + ", C:" + quantizedRotation.c);

// Dequantize rotation data ready for reconstruction after bit-packing
Quaternion rotation = SmallestThree.Dequantize(quantizedRotation);
Serialize/deserialize data
…
Bit-level operations
csharp
/*
Bits   Min Dec    Max Dec     Max Hex     Bytes Used
0-7    0          127         0x0000007F  1 byte
8-14   128        1023        0x00003FFF  2 bytes
15-21  1024       2097151     0x001FFFFF  3 bytes
22-28  2097152    268435455   0x0FFFFFFF  4 bytes
29-32  268435456  4294967295  0xFFFFFFFF  5 bytes
*/

data.Add(9, 256);

uint value = data.Read(9);
Abstract data serialization with Span
…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#dotnetgamedevhigh-performancemulti-threading

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库