SiddiqSoft.asynchrony-lib 0.10.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SiddiqSoft.asynchrony-lib --version 0.10.2                
NuGet\Install-Package SiddiqSoft.asynchrony-lib -Version 0.10.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiddiqSoft.asynchrony-lib" Version="0.10.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SiddiqSoft.asynchrony-lib --version 0.10.2                
#r "nuget: SiddiqSoft.asynchrony-lib, 0.10.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SiddiqSoft.asynchrony-lib as a Cake Addin
#addin nuget:?package=SiddiqSoft.asynchrony-lib&version=0.10.2

// Install SiddiqSoft.asynchrony-lib as a Cake Tool
#tool nuget:?package=SiddiqSoft.asynchrony-lib&version=0.10.2                

asynchrony : Add asynchrony to your apps

CodeQL Build Status alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Motivation

  • We needed to add asynchrony to our code.
  • The code here is a set of helpers that utilize the underlying deque, semaphore, mutex features found in std.
  • Be instructive while providing functional code
  • Use only C++20 standard code: jthread, deque, semaphore, barriers and latch
  • No external dependency

Usage

Refer to the documentation for details.

The library uses concepts to ensure the type T meets move construct requirements.

Single threaded worker

#include "siddiqsoft/asynchrony-lib.hpp"

// Define your data
struct MyWork
{
   std::string urlDestination{};
   std::string data{};
   void operator()(){
      magic_post_to(urlDestination, data);
   }
};

void main()
{
   // Declare worker with our data type and the driver function.
   siddiqsoft::simple_worker<MyWork> worker{[](auto& item){
                                              // call the item's operator()
                                              // to invoke actual work.
                                              item();
                                           }};
   // Fire 100 items
   for( int i=0; i < 100; i++ )
   {
      // Queues into the single worker
      worker.queue({std::format("https://localhost:443/test?iter={}",i),
                    "hello-world"});
   }

   // As the user, you must control the lifetime of the worker
   // Trying to delete the worker will cause it to stop
   // and abandon any items in the internal deque.
   std::this_thread::sleep_for(1s);
}

Multi-threaded worker pool

#include "siddiqsoft/simple_pool.hpp"

void main()
{
   // Declare worker with our data type and the driver function.
   siddiqsoft::simple_pool<MyWork> worker{[](auto& item){
                                           // call the item's operator()
                                           // to invoke actual work.
                                           item();
                                        }};
   // Fire 100 items
   for( int i=0; i < 100; i++ )
   {
      // Queues into the single queue but multiple worker threads
      // (defaults to CPU thread cout)
      worker.queue({std::format("https://localhost:443/test?iter={}",i),
                    "hello-world"});
   }

   // As the user, you must control the lifetime of the worker
   // Trying to delete the worker will cause it to stop
   // and abandon any items in the internal deque.
   std::this_thread::sleep_for(1s);
}

Multi-threaded roundrobin pool

#include "siddiqsoft/roundrobin_pool.hpp"

void main()
{
   // Declare worker with our data type and the driver function.
   siddiqsoft::roundrobin_pool<MyWork> worker{[](auto& item){
                                               // call the item's operator()
                                               // to invoke actual work.
                                               item();
                                             }};
   // Fire 100 items
   for( int i=0; i < 100; i++ )
   {
      // Queues into the thread pools individual queue by round-robin
      // across the threads with simple counter.
      // (defaults to CPU thread cout)
      worker.queue({std::format("https://localhost:443/test?iter={}",i),
                    "hello-world"});
   }

   // As the user, you must control the lifetime of the worker
   // Trying to delete the worker will cause it to stop
   // and abandon any items in the internal deque.
   std::this_thread::sleep_for(1s);
}

<p align="right"> © 2021 Siddiq Software LLC. All rights reserved. </p>

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SiddiqSoft.asynchrony-lib:

Package Downloads
SiddiqSoft.CosmosClient

Azure Cosmos REST-API Client for Modern C++

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 143 10/25/2024
1.0.0 190 10/4/2024
0.11.2 93 10/4/2024
0.11.1 536 6/1/2022
0.11.0 5,825 12/16/2021
0.10.4 619 11/20/2021
0.10.3 364 10/8/2021
0.10.2 472 10/7/2021
0.10.1 5,728 10/6/2021
0.9.1 7,867 9/18/2021