Nalix.Framework¶
Nalix.Framework provides core runtime services for dependency injection, task scheduling, system-wide identifiers, and high-level memory management.
Runtime Services Map¶
flowchart LR
A["InstanceManager"] --> B["Service Registry"]
A --> C["TaskManager"]
B --> D["Application Infrastructure"]
C --> E["Recurring Workers / Cleanup Jobs"]
What belongs here¶
InstanceManagerfor registering and resolving shared services and infrastructure.TaskManagerfor managing named background workers and recurring jobs.Snowflakefor generating 64-bit compact, sortable identifiers.TimingScope(inNalix.Environment) for lightweight, high-precision latency measurement.BufferPoolManagerandObjectPoolManagerfor managing shared resource pools.
Instance Registration¶
InstanceManager is the common registry used across the stack. It can register existing instances or lazily create new ones. It is the preferred way to publish infrastructure such as loggers and packet registries.
Quick Example¶
// Register a logger
InstanceManager.Instance.Register<ILogger>(logger);
// Resolve or create a task manager
TaskManager taskManager = InstanceManager.Instance.GetOrCreateInstance<TaskManager>();
Background Work¶
TaskManager manages the execution and lifecycle of background tasks and recurring jobs. It provides features like group concurrency limits, named workers, and execution reporting.
Quick Example¶
TaskManager manager = InstanceManager.Instance.GetOrCreateInstance<TaskManager>();
manager.ScheduleRecurring(
"session.cleanup",
TimeSpan.FromSeconds(30),
async ct => await CleanupExpiredSessionsAsync(ct));
Identifiers and Timing¶
Snowflakeprovides unique, time-sortable 64-bit IDs suitable for tasks, sessions, and packets.TimingScopeallows for easy measurement of operation duration with minimal overhead.
Memory Management¶
Nalix.Framework owns the management logic for resource pools. While the actual leasing primitives (like BufferLease) live in Nalix.Codec, the managers that own the underlying arrays and objects live here.
BufferPoolManager: Manages pooled pinned byte arrays and buffer trimming policy.ObjectPoolManager: Manages pools of reusable class instances to minimize GC pressure.