/dotnext-skills:dotnext-concurrencyfrom .NEXT
Provides concurrent data structures and allocation-free async building blocks from DotNext.Threading: AsyncLazy, TaskCompletionPipe, reusable ValueTaskCompletionSource, CancellationTokenMultiplexer, AsyncCounter for throttling, AsyncStateTracker, distributed leases, BoundedObjectPool, and SIEVE-based RandomAccessCache.
Ships in .NEXT. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
DotNext.Threading the project references (.csproj or
Directory.Packages.props). This skill describes 6.x. For older versions, verify each
member you use against the XML docs/IntelliSense of the referenced version.DotNext.Threading.AsyncLazy<T>) or with the namespace in parentheses next to it
(e.g. AsyncCounter (DotNext.Threading)). Add the using for that namespace and use the short type name in code.DotNext.Threading.AsyncLazy<T> as async-friendly replacement of System.Lazy<T> class:
resettable: true, and the first caller's token cancels the computation for everyoneDotNext.Threading.Tasks.TaskCompletionPipe<T> as alternative to Task.WhenEach method call in the following cases
Add methodReset methodValueTaskCompletionSource or ValueTaskCompletionSource<T> (DotNext.Threading.Tasks) as alternative to System.Threading.Tasks.TaskCompletionSource or System.Threading.Tasks.TaskCompletionSource<T> classes in cases when the source can be reused between completions to reduce memory allocation
ValueTask or ValueTask<T> it produces must be awaited exactly once and never after Reset(), or the consumer sees the next completion or an exception.DotNext.Threading.CancellationTokenMultiplexer when multiple cancellation tokens need to be linked with each other and/or with the timeout in hot execution paths to replace memory allocation with poolingAsyncCounter (DotNext.Threading) to organize rate limiting or throttling. Back-pressure is controlled by HasConcurrencyLimit and ConcurrencyLevel properties inherited from QueuedSynchronizer base classAsyncStateTracker (DotNext.Threading) to track object changes asynchronously. It can be used to implement System.Collections.Generic.IAsyncEnumerable<T> interface to supply changed versions of the object. The producer calls TryAdvance() on each change and TryComplete() at the end. The consumer takes CurrentState and awaits WaitNextAsync(state, token). That returns false once the tracker is completed. After it returns true, read the resource and take CurrentState again.LeaseConsumer and LeaseProvider<TMetadata> (DotNext.Threading.Leases) abstract types for client-side and server-side distributed leases accordingly
LeaseProvider<TMetadata> needs GetStateAsync and TryUpdateStateAsync implemented over the shared storage (DB, blob, etc.).LeaseConsumer needs TryAcquireCoreAsync, TryRenewCoreAsync and ReleaseCoreAsync, usually as calls to the provider.DotNext.Collections.Concurrent.BoundedObjectPool<T> instead of a custom pool implementation
TryGet() returns null when the pool is empty, so the caller creates the object itself.TryReturn() returns false when the pool is full, so the caller must dispose or drop the object.DotNext.Runtime.Caching.RandomAccessCache<TKey, TValue> class
DotNext.Runtime.Caching.RandomAccessCache<TValue> (where TValue : unmanaged) instead of RandomAccessCache<TKey, TValue> for large caches. It keeps the keys, the values and the SIEVE structures in unmanaged memory, so the cache size doesn't add GC mark work and GC pauses.
RandomAccessCache<TKey, TValue> when the value is or contains a reference type, the value must be updated in place, the cache must be enumerated, entries need weights or the cache must grow (RandomAccessCache<TKey, TValue, TWeight>), the key needs a custom IEqualityComparer<TKey>, or the cache is small enough that GC cost doesn't matter.RandomAccessCache.AsKey(ReadOnlyMemory<byte>) or RandomAccessCache.AsKey(string) for ChangeAsync, ReplaceAsync, TryRemoveAsync and InvalidateAsync. These wrappers convert implicitly to ReadOnlySpan<byte> for TryRead and Contains, so use the same wrapper for reading and writing: AsKey(string) uses the UTF-16 bytes of the string, not UTF-8.ReplaceAsync to put a new value under the same key.Eviction callback to clean up after the removed value. It is called once per record, after all the sessions of the record are closed. The key passed to the callback is valid only during the call.MeasurementTags sets the tags for its metrics (number of entries and allocated unmanaged memory).ReferenceCounted<T> and ReferenceCountedOwner<T> classes (DotNext.Threading) to replace handwritten reference counting mechanismDotNext.Threading.Atomic<T> container type for synchronized access to the custom struct instead classic monitor lock. This type has no contention between concurrent readers, so multiple threads can read the value in parallel. But all writers are serialized.
RandomAccessCache<TValue> (returned by TryRead, ChangeAsync, ReplaceAsync, TryRemoveAsync and their synchronous overloads) must be disposed. An undisposed session leaks the unmanaged memory of its entry, and an undisposed write session holds the bucket lock and blocks the disposal of the cache. Don't use ReadSession.Value, ValueRef or Key after disposing the session.RandomAccessCache<TValue> explicitly. The finalizer of an abandoned cache releases the memory, but it doesn't call the Eviction callback.RandomAccessCache.AsKey must not change until the session is disposed, because the key is read twice: to find the bucket and to copy it to the entry.Atomic<T> is a mutable struct. Store it in a non-readonly field and access it by reference. A copy is an independent value with no synchronization with the original.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dotnet/dotnext --plugin dotnext-skills4 skills in this plugin
/dotnext-coreCore types from the DotNext NuGet package - Optional<T> and Result<T> monads, Optional JSON serialization (PATCH DTOs with omitted fields), Timestamp, EnumType attribute lookup, ConsoleLifetimeTokenSource, TypeMap/ConcurrentTypeMap, LocalReference and UserData. Use when expressing absent values or errors without exceptions; when distinguishing undefined and null JSON fields; when measuring elapsed time or tracking deadlines; when reading attributes of enum members; when handling console app shutdown (Ctrl+C, SIGTERM) without a generic host; when a dictionary is keyed by System.Type; when a ref field to a ref struct is needed; or when attaching data to objects via ConditionalWeakTable./dotnext-memoryAllocation-free memory routines from the DotNext and DotNext.Unsafe NuGet packages - SpanOwner (safe stackalloc with pooled fallback), BufferWriterSlim (stack-allocated StringBuilder/buffer replacement with string interpolation), PoolingBufferWriter, PoolingArrayBufferWriter, SparseBufferWriter, and the MemoryAllocator abstraction over ArrayPool, plain arrays and unmanaged memory. Use when reducing allocations in .NET hot paths; when stackalloc length comes from input; when replacing StringBuilder, MemoryStream, RecyclableMemoryStream, ArrayBufferWriter or manual ArrayPool rent/return code; or when making the memory allocation strategy configurable./dotnext-threadingAsync synchronization primitives from the DotNext.Threading NuGet package - async exclusive and reader/writer locks (with sync acquisition for mixed callers), auto/manual reset events, countdown event, barrier, AsyncTrigger, awaiting WaitHandle/CancellationToken, and custom primitives via QueuedSynchronizer<T>. Use when writing async .NET code that needs mutual exclusion or signaling without blocking threads, or that must await a WaitHandle or a CancellationToken; and when converting lock/Monitor, Monitor.Wait/Pulse, ReaderWriterLockSlim, ManualResetEventSlim, AutoResetEvent, CountdownEvent, Barrier or WaitHandle.WaitOne to async, e.g. after "CS1996 cannot await in the body of a lock statement".Other plugins' skills for the same job