GithubHelp home page GithubHelp logo

codefork / scheduler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rvhuang/scheduler

0.0 2.0 0.0 236 KB

A thread-safe asynchronous producer-consumer model.

Home Page: https://rvhuang.github.io/Scheduler/

License: MIT License

C# 100.00%

scheduler's Introduction

Scheduler

Overview

Scheduler is an asynchronous producer-consumer model that allows producers concurrently add items to the collection and consumes each item from the collection in single thread.

Overview

The flow can be summarized with following steps:

  1. A producer adds an item to the collection by calling AddAndRun or TryAddAndRun method.
  2. Scheduler checks whether the item is the first one in the collection. If so, the main loop thread will be launched.
  3. Action consumes the item from the collection.
  4. Scheduler checks whether the collection is empty. If so, main loop thread ends. If not, repeats step 3.

The Scheduler performs following behaviors to handle main loop thread:

  • If the collection implements INotifyCollectionChanged interface, when CollectionChanged event is fired to notify that new items has been added, the main loop thread will also be launched if it is in idle.
  • Main loop thread can be canceled at any time with Stop method, and resumed with Run method.

Redis Integration

This project defines a set of Redis wrapper that can be used to replace in-memory collection. In this scenario, items are stored in Redis list instead of local memory and wrapped by RedisQueue or RedisStack. This can avoid large local memory use when a number of items are not consumed yet.

Overview Redis

By applying ObservableRedisQueue or ObservableRedisStack, which implements INotifyCollectionChanged interface, it is also possible that multiple application instances share same collection. Once new items have been added via an application instance, all instances sharing same Redis collection will receive the notification and start the main loop thread respectively.

Overview Observable Redis

The Redis wrappers are defined in ModelWorkshop.Scheduling.Redis namespace.

Platforms

This project targets .Net Core and .Net Framework 4.5.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.