All Projects → VSoftTechnologies → Vsoft.awaitable

VSoftTechnologies / Vsoft.awaitable

Licence: apache-2.0
Async/Await for Delphi

Programming Languages

pascal
1382 projects
delphi
115 projects

Projects that are alternatives of or similar to Vsoft.awaitable

Async Io Demo
demo for rust asynchronous io: from mio to stackless coroutine
Stars: ✭ 334 (+1184.62%)
Mutual labels:  async-await
Thunks
A small and magical composer for all JavaScript asynchronous.
Stars: ✭ 523 (+1911.54%)
Mutual labels:  async-await
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+2553.85%)
Mutual labels:  async-await
Anyio
High level compatibility layer for multiple asynchronous event loop implementations on Python
Stars: ✭ 343 (+1219.23%)
Mutual labels:  async-await
Aiomonitor
aiomonitor is module that adds monitor and python REPL capabilities for asyncio application
Stars: ✭ 430 (+1553.85%)
Mutual labels:  async-await
Chillout
Reduce CPU usage by non-blocking async loop and psychologically speed up in JavaScript
Stars: ✭ 565 (+2073.08%)
Mutual labels:  async-await
Duckduckgo
DuckDuckGo App built in React-Native (Unofficial)
Stars: ✭ 320 (+1130.77%)
Mutual labels:  async-await
Async Reduce
Reducer for similar simultaneously coroutines
Stars: ✭ 17 (-34.62%)
Mutual labels:  async-await
Basic Ftp
FTP client for Node.js, supports FTPS over TLS, passive mode over IPv6, async/await, and Typescript.
Stars: ✭ 441 (+1596.15%)
Mutual labels:  async-await
P Map
Map over promises concurrently
Stars: ✭ 639 (+2357.69%)
Mutual labels:  async-await
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (+1207.69%)
Mutual labels:  async-await
Trio
Trio – a friendly Python library for async concurrency and I/O
Stars: ✭ 4,404 (+16838.46%)
Mutual labels:  async-await
Kretes
A Programming Environment for TypeScript & Node.js built on top of VS Code
Stars: ✭ 570 (+2092.31%)
Mutual labels:  async-await
P Iteration
Utilities that make array iteration easy when using async/await or Promises
Stars: ✭ 337 (+1196.15%)
Mutual labels:  async-await
Typescript Fundamentals
👨‍🏫 Mike's TypeScript Fundamentals Course
Stars: ✭ 732 (+2715.38%)
Mutual labels:  async-await
Promise Fun
Promise packages, patterns, chat, and tutorials
Stars: ✭ 3,779 (+14434.62%)
Mutual labels:  async-await
Posterus
Composable async primitives with cancelation, control over scheduling, and coroutines. Superior replacement for JS Promises.
Stars: ✭ 536 (+1961.54%)
Mutual labels:  async-await
Then
🎬 Tame async code with battle-tested promises
Stars: ✭ 908 (+3392.31%)
Mutual labels:  async-await
Awaity.js
A functional, lightweight alternative to bluebird.js, built with async / await in mind.
Stars: ✭ 818 (+3046.15%)
Mutual labels:  async-await
Node Express Mongodb Jwt Rest Api Skeleton
This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API). Demo of frontend in VueJS here: https://github.com/davellanedam/vue-skeleton-mvp
Stars: ✭ 603 (+2219.23%)
Mutual labels:  async-await

VSoft.Awaitable

This is a simple library for making Asynchronous function calls. It is a wrapper over OmniThreadLibrary and is based on it's own Parallel.Async functionality.

Parallel.Async does not provide a simple way to cancel calls, and be notified of the cancellation, and it does not allow the returning of results.

Usage

Include VSoft.Awaitable in your uses clause.

    TAsync.Configure<string>(
        function (const cancelToken : ICancellationToken) : string
        var
          i: Integer;
        begin
            result := 'Hello ' + value;
            for i := 0 to 2000 do
            begin
              Sleep(1);
              //in loops, check the token
              if cancelToken.IsCancelled then
                exit;
            end;

            //where api's can take a handle for cancellation, use the token.handle
            WaitForSingleObject(cancelToken.Handle,5000);

            //any unhandled exceptions here will result in the on exception proc being called (if configured)
            //raise Exception.Create('Error Message');
        end, token);
    )
    .OnException(
        procedure (const e : Exception)
        begin
          Label1.Caption := e.Message;
        end)
    .OnCancellation(
        procedure
        begin
            //clean up
            Label1.Caption := 'Cancelled';
        end)
    .Await(
        procedure (const value : string)
        begin
            //use result
            Label1.Caption := value;
        end);

You can also return IAwaitable<TResult> from functions

function LoadAsyncWithToken (const token : ICancellationToken; const value : string) : IAwaitable<string>;
begin
  //configure our async call and return the IAwaitable<string>
  result := TAsync.Configure<string>(
        function(const cancelToken : ICancellationToken) : string
        begin
            //.... do some long running thing
            result := 'Hello ' + value;
        end, token);
end;

// for when there is no result to return
function RunIt (const token : ICancellationToken; const value : string) : IAwaitable;
begin
  //configure our async call and return the IAwaitable<string>
  result := TAsync.Configure(
        procedure(const cancelToken : ICancellationToken)
        begin
        //.... do some long running thing
        end, token);
end;


procedure UseIt;
begin
     LoadAsyncWithToken('param', FTokenSource.Token)
     .OnException(
        procedure (const e : Exception)
        begin
          Label1.Caption := e.Message;
        end)
    .OnCancellation(
        procedure
        begin
            //clean up
            Label1.Caption := 'Cancelled';
        end)
    .Await(
        procedure (const value : string)
        begin
            //use result
            Label1.Caption := value;
        end);

     RunIt('param', FTokenSource.Token)
     .OnException(
        procedure (const e : Exception)
        begin
          Label1.Caption := e.Message;
        end)
    .OnCancellation(
        procedure
        begin
            //clean up
            Label1.Caption := 'Cancelled';
        end)
    .Await(
        procedure
        begin
            //use result
            Label1.Caption := 'Done';
        end);


Note that Await actually invokes the async function. There is also an overload to TAsync.Configure that does not take a cancellation token for when you don't need to cancel.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].