Code Monkey home page Code Monkey logo

yaclib's Issues

Write benchmarks for IThreadPool

Add benchmarks relative to the master.
It is proposed to measure push and execution of 4 types:
A task that is executed faster than

  1. 1 us
  2. 1 ms
  3. 1 sec
  4. 1 min

Codecov fix

Code coverage dont check header files, to avoid checking another libraries.

  • Understand how to fix this for our internal headers

Lazy Future 1

Check researches and implementations of shared future (e.g. libunifex, articles, etc.). Try to design and implement this abstraction.

  • Add lazy::Run, which returns a special object (Sender concept): save functor on the stack and make method Get which return Future.
  • Make method for Sender with same semantic as Future::Then.

Add clang-tidy

Use all checks, otherwise, we will discuss which ones to disable in PR

Necessary for #6

Implement IMailBoxExecutor

This class execute only last N tasks using IExecutorPtr.

To implement use SPSC lock-free fixed-size queue (ring buffer)

Add stackfull coroutine

Recommend to look at this link https://www.agner.org/optimize

Implement IThreadFactory

This class should help to set service values for thread pool threads:

  • Name
  • Priority
  • Callbacks before starting using thread IThreadPool, after ending using thread IThreadPool

It is also a cache of threads between the operating system and a set of user IThreadPool's with a dynamic size or lifetime that is different from the lifetime of the program.

Write good callback abstraction

ITask <=> Intrusive node + vtable + virtual void Call() = 0

detail::Task(functor<void()>) -> Functor member + public inheritance ITask, void Call() call functor<void()>

detail::CallbackTask(functor<void(Args...)>) -> Functor member + raw memory for Args + public inheritance ITask, void Call() call functor<void(Args...)>(Args...), method some like SetArgs(Args...)

CreateCallback <=> detail::CallbackTask(functor<void(Args...)>)
when we should execute callback and know its args we:
callback->SetArgs(args...);
tp->Execute(callback)
or if inline callback call
callback->Call(args....)

Implement AsyncMutex

This class Execute() tasks strictly sequentially using IExecutorPtr.
To implement use Wait-free MPSC queue

Add CI

  • Use GitHub actions
  • Build library, tests, benchmarks for all checked configurations
    • Linux + Clang
    • Linux + GCC
    • Windows + MSVC
    • OS X + AppleClang
    • Windows + other compilers (if possible)
    • Android + GCC (if possible)
    • Android + Clang (if possible)
    • IOS + AppleClang (if possible)
  • Check with clang-format
  • Check with clang-tidy #8
  • Run tests with sanitizers #7

Add SharedFuture

First of feel free to ask me(@MBkkt) any questions about this task, often the task may not be described in enough detail for devs who don't have the full context.

Make T SharedFuture<T>::Get() const;
"Allocate" the mutex inside the SharedFuture class, not on the stack as is the case with T Future::Get() &&

Add WhenAll for futures

WhenAll combinator
Container<Future> -> Future<Container>
Container<Future> -> Future
Container maybe any std container or Args...

Improve docs

MAKE IT BETTER

  • #108
  • #107
  • Fix typo, grammar, etc
  • Fix undocumentated API
  • Translate design doc to English and separate design/done/plan

Write fault injection thread interface for STL

https://en.cppreference.com/w/cpp/thread

yaclib::std::

C++ 17:

  • thread
  • get_id
  • yield
  • sleep_for
  • sleep_until
  • mutex
  • timed_mutex
  • recursive_mutex
  • shared_mutex
  • shared_timed_mutex
  • once_flag
  • call_once
  • condition_variable
  • condition_variable_any

C++ 20:

  • jthread
  • counting_semaphore
  • binary_semaphore
  • latch
  • barrier
  • atomic::wait/notify_one/all

Maybe?

  • notify_all_at_thread_exit
  • jthread::stop_token
  • Thread cancellation

Definitely no.

  • promise
  • packaged_task
  • future
  • shared_future
  • async

Add WaitGroup

  • Remove CallerCore
  • Test ITask::Cancel
  • Add WaitGroup: wait many futures without their invalidation and without overhead expect one mutex/condvar
struct WaitGroup { // not copy/move
  template<typename T>
  void Add(Future<T>& f) &;

  void Wait() &;
};

Write abstraction for void() functor

This abstraction will have to be used in intrusive containers.
Therefore, it needs to be allocated on the heap and there should be pointers to prev/next in it.

And don't forget to write tests

Improve WhenAll/Any

Main idea to create:

  • Future<void> WhenAll(...); ... can be any type of futures
  • Future<vector<T>> TakeAll(...); ... can be same type of futures
  • Future<std::tuple<T...>> TakeAllArgs(...); ... can be any type of futures
  • Future<void> WhenAny(...); ... can be any type of futures
  • Future<vector<T>> TakeAny(...); ... can be same type of futures
  • Future<std::tuple<T...>> TakeAnyArgs(...); ... can be any type of futures

Implement IMailBoxTask

IMailBoxTask это ITask с несколькими особенностями

  • Владение ею шарится между пользователем и IExector (Если это не так то не используйте ее)
  • В параметре конструктора она принимает число N, это число сколько раз она исполнится:
    Приведу паттерн использования:
auto task = CreateMailBoxTask(2, lamdda)
// when timer tick
any_executor->Execute(task);

Хочется, чтобы таска исполнялась минимальное число раз между количеством тиков и N.
Собственно N будет строгим минимумом тогда когда тики происходят быстрее чем таска исполняется,

TODO(MBkkt) Лучшее описание

Add documentation

Write basic documentation using GitHub Flavored Markdown:

  • /README.md - table of contents = links to other documentation entries.
  • /docs/README.md - library overview.
  • /docs/INSTALL.md - prerequisites and install options.
  • /docs/DEPENDENCIES.md - library build dependencies.
  • /docs/CODESTYLE.md - additional code style information (i. e. entries which couldn't be put in .clang-format).

Create library

  • Use CMake
  • Make library static
  • Create project structure like:
    • /                                        // root
    • /include/yaclib                  // public header files
    • /include/yaclib/executor   // executors
    • /include/yaclib/future       // future/promise
    • /src                                  // all source and private header files
    • /src/executor                   // executors
    • /src/future                       // future/promise
    • /test                                // tests
    • /bench                            // benchmarks
    • /doc                                // library overview and design docs
    • /example                        // example of library usage

Fix link with headers in doxygen

If we mix headers and links in markdown it incorrect render in doxygen. (For example, check SANITIZERS.md). Check how to fix this doxygen bug

YACLib

  1. Don't forget to add @MBkkt to all PR
  2. If the issue has no assignees or only @MBkkt is listed. You can ask for it yourself.
  3. If @MBkkt is indicated in the issue as the assignee, you need to additionally discuss the implementation with him.

Add WhenAny for futures

WhenAny combinator
Container<Future> -> Future
Container maybe any std container or Args...

Write different implementations of IThreadPool and benchmark it

  • Implement good TestAndSet spinlock

Write different implementations IThreadPool

  • IntusiveList with std::mutex
  • IntusiveList with spinlock
  • IntusiveList with std::mutex per thread
  • IntusiveList with spinlock per thread
  • Michael Scott queue
  • Michael Scott queue per thread
  • Lock-free MPSC queue with std::mutex for consumers
  • Lock-free MPSC queue with spinlock for consumers
  • Lock-free MPSC queue per thread
  • Lock-free MPSC queue with std::mutex and per-thread SPSC queue for consumers
  • Lock-free MPSC queue with spinlock and per-thread SPSC queue for consumers
  • Lock-free deque
  • Lock-free deque per thread

And whatever else you can invent

  • Benchmark their

P.S. per thread means you should use work-stealing or work-distribution

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.