All Projects → sharow → Libconcurrent

sharow / Libconcurrent

Licence: zlib
©️ Concurrent Programming Library (Coroutine) for C11

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Libconcurrent

YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (-42.39%)
Mutual labels:  concurrency, concurrent, coroutine
Util
A collection of useful utility functions
Stars: ✭ 201 (-40%)
Mutual labels:  concurrency, concurrent
Concurrent
concurrency utilities
Stars: ✭ 186 (-44.48%)
Mutual labels:  concurrency, concurrent
practice
Java并发编程与高并发解决方案:http://coding.imooc.com/class/195.html Java开发企业级权限管理系统:http://coding.imooc.com/class/149.html
Stars: ✭ 39 (-88.36%)
Mutual labels:  concurrency, concurrent
Freelancer
👔 An implementation of on-the-fly defined WebWorkers that are created inline using data URIs, rather than separate physical files — for the benefit of all humanity.
Stars: ✭ 57 (-82.99%)
Mutual labels:  concurrency, concurrent
Goconcurrentqueue
Go concurrent-safe, goroutine-safe, thread-safe queue
Stars: ✭ 127 (-62.09%)
Mutual labels:  concurrency, concurrent
Hunch
Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive.
Stars: ✭ 94 (-71.94%)
Mutual labels:  concurrency, concurrent
treap
A thread-safe, persistent Treap (tree + heap) for ordered key-value mapping and priority sorting.
Stars: ✭ 23 (-93.13%)
Mutual labels:  concurrency, concurrent
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-94.03%)
Mutual labels:  concurrency, coroutine
python3-concurrency
Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别
Stars: ✭ 49 (-85.37%)
Mutual labels:  concurrency, coroutine
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+107.46%)
Mutual labels:  concurrency, concurrent
Zio
ZIO — A type-safe, composable library for async and concurrent programming in Scala
Stars: ✭ 3,167 (+845.37%)
Mutual labels:  concurrency, concurrent
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+54.33%)
Mutual labels:  concurrency, concurrent
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (-57.01%)
Mutual labels:  concurrency, concurrent
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (+1.49%)
Mutual labels:  concurrency, coroutine
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (-92.84%)
Mutual labels:  concurrency, concurrent
concurrency-kit
🚄 Concurrency abstractions framework for Apple Platforms [Task, Atomic, Lock, Operation, etc.].
Stars: ✭ 17 (-94.93%)
Mutual labels:  concurrency, concurrent
Python3 Concurrency Pics 02
爬取 www.mzitu.com 全站图片,截至目前共5162个图集,16.5万多张美女图片,使用 asyncio 和 aiohttp 实现的异步版本只需要不到2小时就能爬取完成。按日期创建图集目录,保存更合理。控制台只显示下载的进度条,详细信息保存在日志文件中。支持异常处理,不会终止爬虫程序。失败的请求,下次再执行爬虫程序时会自动下载
Stars: ✭ 275 (-17.91%)
Mutual labels:  concurrency, coroutine
Tofu
Functional programming toolbox
Stars: ✭ 281 (-16.12%)
Mutual labels:  concurrent
S task
awaitable coroutine library for C
Stars: ✭ 317 (-5.37%)
Mutual labels:  coroutine

libconcurrent

zlib License

tiny asymmetric-coroutine library.

Description

  • asymmetric-coroutine
  • bidirectional communication by yield_value/resume_value
  • native context switch
  • C11

Supported Platforms

x86_64 i686 ARM(v6/v7) note
Linux ✔️ ✔️ ✔️
FreeBSD ✔️ ✔️ Thanks @t6
OSX ✔️ ✖️ ✖️ Thanks @kpamnany

Code Example

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdnoreturn.h>

#include <concurrent/concurrent.h>
#include <concurrent/shortname.h>

#define STACK_SIZE (1024 * 2)


noreturn void accumulator(struct concurrent_ctx *ctx)
{
    int *v = ctx_get_resume_value(ctx);
    int total = *v;
    for (;;) {
        v = yield_value(ctx, &total); // send total / receive next value
        total += *v;
    }
}

int main(void)
{
    struct concurrent_ctx *ctx;
    uint8_t stack[STACK_SIZE];
    uint8_t ctx_alloc[ctx_sizeof()];
    concurrent_init();
    ctx = (struct concurrent_ctx *)ctx_alloc;
    ctx_construct(ctx, stack, STACK_SIZE, accumulator, NULL);
    for (int i = 1; i <= 10; i++) {
        int *total = resume_value(ctx, &i); // send value / receive total
        printf("total = %d\n", *total);
        
    }
    ctx_destruct(ctx);
    concurrent_fin();
    return EXIT_SUCCESS;
}

/*
$ gcc -o sample sample.c -lconcurrent.a
$ ./sample
total = 1
total = 3
total = 6
total = 10
total = 15
total = 21
total = 28
total = 36
total = 45
total = 55
*/

Requirements for build

Installation

$ git clone https://github.com/sharow/libconcurrent.git libconcurrent
$ cd libconcurrent
$ make
$ sudo make install

for FreeBSD

Available in ports collection as devel/libconcurrent

for OSX

$ brew install nasm

Tests

$ make test

Benchmark

examples/many_context1.c:

-- output: (Xeon E3 2.5Ghz)
3000000 context switch in 373.5 ms
one context switch in 125 ns
8031333 resume/yield pair per second


-- output: (RaspberryPi2 ARMv7 900MHz)
3000000 context switch in 2861.8 ms
one context switch in 954 ns
1048287 resume/yield pair per second

VS.

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].