Giter Site home page Giter Site logo

concurrency-rs's Introduction

Примеры конкурентного программирования на Rust

  • Блокировки (locks) на атомарных переменных:

src/mutex.rs - реализация spinlock и spinlockticket (спинлок c билетами) на атомарных переменных.

src/bin/mutex - тестирование быстродействия данных блокировок с мютексом. Алгоритм заключается в подсчете счетчика при попеременном переключении между 2 потоками, в тест также добавлена реализация mutex на атомарных переменных (mutex on atomic)

Lock Execution time
SpinlockTicket 701 ms
Mutex 250 ms
Mutex on atomic 250 ms
Spinlock 108 ms
  • Пул потоков (Threadpool):

src/threadpool.rs - реализация пула потоков

src/bin/threadpool.rs - тестирования производительности пула потоков.

Count threads Execution time
1 17712 ms
6 3590 ms
  • Примеры отложенной инициализации (lazy static):

src/bin.lazy.rs - непосредственно примеры, с использование Once, OnceLock и с применением атомарных переменных. Также тест производительности

Used primitive Execution time
Once 76 ms
AtomicU64 76 ms
OnceLock (reference) 843 ms
LazyLock (reference) 843 ms
AtomicPtr (reference) 891 ms
  • Потокобезопасный генератор ID на атомарной переменной (Generator ID):
Generator Execution time
Simple atomic 293 ms
Atomic with check 688 ms
Used mutex 571 ms

src/bin/generatorid.rs - непосредственно пример генератора и тесты производительности

concurrency-rs's People

Contributors

kedess avatar

Watchers

Lucian avatar  avatar  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.