Giter Site home page Giter Site logo

zhangminghe / dedicatedthreadpool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from helios-io/dedicatedthreadpool

0.0 0.0 0.0 3 MB

An instanced, dedicated ThreadPool for eliminating "noisy neighbor" problems on the CLR ThreadPool

License: Apache License 2.0

Shell 6.10% C# 51.98% F# 17.58% PowerShell 24.28% Batchfile 0.05%

dedicatedthreadpool's Introduction

DedicatedThreadPool

An instanced, dedicated thread pool for eliminating "noisy neighbor" problems on the CLR ThreadPool.

Installation

You can install DedicatedThreadPool via NuGet!

PS> Install-package Helios.DedicatedThreadPool

This package doesn't install any binaries, just the following C# file: Helios.Concurrency.DedicatedThreadPool.cs - which contains the DedicatedThreadPool, DedicatedThreadPoolTaskScheduler, and DedicatedThreadPoolSettings classes.

API

You can create a Helios.Concurrency.DedicatedThreadPool instance via the following API:

using (var threadPool = new Helios.Concurrency.DedicatedThreadPool(
        new DedicatedThreadPoolSettings(numThreads)))
{
    threadPool.QueueUserWorkItem(() => { ... }));
}

This creates a DedicatedThreadPool object which allocates a fixed number of threads, each with their own independent task queue.

This DedicatedThreadPool can also be used in combination with a DedicatedThreadPoolTaskScheduler for TPL support, like this:

//use 3 threads
var Pool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(3));
var Scheduler = new DedicatedThreadPoolTaskScheduler(Pool);
var Factory = new TaskFactory(Scheduler);

 var task = Factory.StartNew(() =>
{
    //work that'll run on the dedicated thread pool...
});

task.Wait();

NOTE: DedicatedThreadPool is marked as internal by default, so it can be used opaquely across many dependent projects.

Benchmark

Latest benchmark on our build server (2 core Windows Azure A2 medium)

Helios.DedicatedThreadPool v0.3

      Metric |       Units / s |         Max / s |     Average / s |         Min / s |      StdDev / s |

---------------- |---------------- |---------------- |---------------- |---------------- |---------------- | [Counter] BenchmarkCalls | operations | 9,998,100.36 | 8,661,529.31 | 7,093,003.46 | 944,954.17 |

System.Threading.ThreadPool

      Metric |       Units / s |         Max / s |     Average / s |         Min / s |      StdDev / s |

---------------- |---------------- |---------------- |---------------- |---------------- |---------------- | [Counter] BenchmarkCalls | operations | 2,651,289.19 | 2,510,678.63 | 2,098,882.55 | 179,585.24 |

License

See LICENSE for details.

Copyright (C) 2015-2016 Roger Alsing, Aaron Stannard, Jeff Cyr

dedicatedthreadpool's People

Contributors

aaronontheweb avatar huysentruitw avatar rogeralsing avatar kekekeks avatar

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.