npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

com.dots.dispatcher

v1.0.17

Published

Events for Entities and Roslyn Generator for Cleanup events

Downloads

6

Readme

openupm

DOTS Dispatcher

DOTS Dispatcher is a simple yet performant entity as event system to be used with Unity's DOTS ECS.

Entities are created with the corresponding data and will live for one frame.

Since the events are entities, they are fully compatible with the Entities API and they may be queried whatever way suits you best.

Usage

DOTS Dispatcher provides an abstract DispatcherSystem.

The DispatcherSystem must be inherited by a new class that must be running in the SystemGroup of your choice.

Once the system is created, multiple NativeQueue<T> can be created through the system API method CreateDispatcherQueue<T>() and populated with the desired events data.

Events will be created when the corresponding DispatcherSystem runs.

Depending of the execution order they will be created with a one frame delay, and it's important to have this detail in mind when designing your data flow.

Examples

  • DispatcherSystem Declaration
public class SimulationDispatcherSystem : DispatcherSystem
{
}
  • Event Data Declaration
public struct ZeroSizeTestData : IComponentData
{
}

public struct TestData : IComponentData
{
    public int Value;
}
  • Produce Event
public class EventProducerSystem : SystemBase
{
    DispatcherSystem _dispatcherSystem;

    protected override void OnCreate()
    {
        base.OnCreate();

        _dispatcherSystem = World.GetExistingSystem<SimulationDispatcherSystem>();
    }

    protected override void OnUpdate()
    {
        var dispatcherQueue = _dispatcherSystem.CreateDispatcherQueue<ZeroSizeTestData>();
        
        for (var index = 0; index < 0xFF; index++)
        {
            dispatcherQueue.Enqueue(default);
        }
    }
}

public class EventProducerJobSystem : SystemBase
{
    DispatcherSystem _dispatcherSystem;

    protected override void OnCreate()
    {
        base.OnCreate();

        _dispatcherSystem = World.GetExistingSystem<SimulationDispatcherSystem>();
    }

    protected override void OnUpdate()
    {
        // DispatcherQueue is a NativeQueue<T>, thus, fully supported by jobs.
        var dispatcherQueue = _dispatcherSystem.CreateDispatcherQueue<TestData>().AsParallelWriter();
        
        // Just and example on how to create events in jobs.
        Entities
            .WithAll<ZeroSizeTestData>()
            .ForEach((Entity entity) => 
            {
                dispatcherQueue.Enqueue(new TestData { Value = entity.Index });
            })
            .ScheduleParallel();
        
        // Since this system is producing events in Jobs, i.e. asynchronously, 
        // it must be declared as a dependency for the DispatcherSystem through this API call.
        _dispatcherSystem.AddJobHandleForProducer(Dependency);
    }
}
  • Consume Events
public class EventConsumerSystem : SystemBase
{
    EntityQuery _zeroSizeTestDataQuery;

    protected override void OnCreate()
    {
        base.OnCreate();

        _zeroSizeTestDataQuery = GetEntityQuery(ComponentType.ReadOnly<ZeroSizeTestData>());
    }

    protected override void OnUpdate()
    {
        // Examples. Query the entity events as you please.
    
        Debug.Log(_zeroSizeTestDataQuery.CalculateEntityCount());
        
        Entities
            .ForEach((TestData testData) => 
            {
                // Do whatever you want with it.
            })
            .ScheduleParallel();
    }
}