wave4-native-parallel-multihashmap-parallel-writer

Insert values into a NativeParallelMultiHashMap using AsParallelWriter in Unity DOTS jobs.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill wave4-native-parallel-multihashmap-parallel-writer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wave4-native-parallel-multihashmap-parallel-writer
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-dots/wave4-native-parallel-multihashmap-parallel-writer
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill wave4-native-parallel-multihashmap-parallel-writer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you write lock-free parallel jobs that insert many entity values into a shared hash map without race conditions or heavy synchronization.

Core Features & Use Cases

  • Lock-free parallel writing: Uses AsParallelWriter() so multiple worker threads can safely add entries concurrently.
  • Multi-value per key support: Uses NativeParallelMultiHashMap<TKey, TValue> to store multiple values under the same spatial/key bucket.
  • Scatter-gather workflows: Enables a fast parallel “scatter” stage followed by a subsequent (often sequential) “gather/read” stage to process the results.

Quick Start

Use NativeParallelMultiHashMap<int,int>.AsParallelWriter() in a Burst job to add per-entity indices into spatial hash buckets, then read the filled map in a separate job to process each key’s values.

Frequently Asked Questions about wave4-native-parallel-multihashmap-parallel-writer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I insert into a NativeParallelMultiHashMap from multiple Unity DOTS jobs?

To insert into a NativeParallelMultiHashMap from multiple parallel jobs, call AsParallelWriter() on the map and pass the writer into your Burst job. This enables lock-free concurrent additions across worker threads without race conditions.

What is the best way to do spatial hashing in Unity ECS without synchronization locks?

Lock-free spatial hashing is achieved by using NativeParallelMultiHashMap with AsParallelWriter. Multiple worker threads safely scatter entity indices into spatial buckets concurrently, followed by a sequential gather stage to read the results.

Can I read from a NativeParallelMultiHashMap while using AsParallelWriter?

You cannot read from the map using the parallel writer. Thread-safety requirements restrict reads to non-parallel access, meaning you must schedule a separate subsequent job to gather and process the inserted values sequentially.

How does AsParallelWriter handle multiple values for the same key in Unity DOTS?

AsParallelWriter works with NativeParallelMultiHashMap to support multi-value buckets. When multiple threads insert entries with the same key, the writer safely chains the values together, enabling scatter-gather workflows for grouping entities.

Why does my NativeParallelMultiHashMap parallel insert fail with capacity errors?

Parallel inserts fail when the map lacks adequate capacity. You must enforce sufficient capacity using the appropriate allocator before scheduling jobs, ensuring the map has enough memory for all concurrent entries added by worker threads.