All Projects → Zewo → Venice

Zewo / Venice

Licence: mit
Coroutines, structured concurrency and CSP for Swift on macOS and Linux.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Venice

Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines.
Stars: ✭ 1,856 (+23.65%)
Mutual labels:  coroutines, non-blocking, fibers, server-side-swift, swiftpm, green-threads
Reflection
DEPRECATED
Stars: ✭ 592 (-60.56%)
Mutual labels:  server-side-swift, server, swiftpm
Poseidon
Poseidon Server Framework (refactor WIP)
Stars: ✭ 162 (-89.21%)
Mutual labels:  coroutines, fibers, server
Hummingbird
Lightweight, flexible HTTP server framework written in Swift
Stars: ✭ 114 (-92.41%)
Mutual labels:  server-side-swift, server
Sockets
🔌 Non-blocking TCP socket layer, with event-driven server and client.
Stars: ✭ 559 (-62.76%)
Mutual labels:  non-blocking, server-side-swift
Chillout
Reduce CPU usage by non-blocking async loop and psychologically speed up in JavaScript
Stars: ✭ 565 (-62.36%)
Mutual labels:  non-blocking, performance
Vibora
Fast, asynchronous and elegant Python web framework.
Stars: ✭ 5,734 (+282.01%)
Mutual labels:  server, performance
Fibertaskinglib
A library for enabling task-based multi-threading. It allows execution of task graphs with arbitrary dependencies.
Stars: ✭ 679 (-54.76%)
Mutual labels:  coroutines, fibers
Vertx Sql Client
High performance reactive SQL Client written in Java
Stars: ✭ 690 (-54.03%)
Mutual labels:  non-blocking, performance
Aws Sdk
Using vertx-client for AWS SDK v2
Stars: ✭ 38 (-97.47%)
Mutual labels:  non-blocking, performance
Kitura
A Swift web framework and HTTP server.
Stars: ✭ 7,533 (+401.87%)
Mutual labels:  server-side-swift, server
Gaia
C++ framework for rapid server development
Stars: ✭ 58 (-96.14%)
Mutual labels:  fibers, server
Elle
The Elle coroutine-based asynchronous C++ development framework.
Stars: ✭ 459 (-69.42%)
Mutual labels:  coroutines, fibers
Iris
The fastest HTTP/2 Go Web Framework. AWS Lambda, gRPC, MVC, Unique Router, Websockets, Sessions, Test suite, Dependency Injection and more. A true successor of expressjs and laravel | 谢谢 https://github.com/kataras/iris/issues/1329 |
Stars: ✭ 21,587 (+1338.17%)
Mutual labels:  server, performance
Swiftserverside Vapor
🦄 Swift server open source projects based on the Swift 4.1 and Vapor 3 frameworks. (Swift 服务端开源项目)
Stars: ✭ 588 (-60.83%)
Mutual labels:  server-side-swift, server
Vapor
💧 A server-side Swift HTTP web framework.
Stars: ✭ 21,194 (+1311.99%)
Mutual labels:  server-side-swift, server
Taskscheduler
Cross-platform, fiber-based, multi-threaded task scheduler designed for video games.
Stars: ✭ 402 (-73.22%)
Mutual labels:  fibers, performance
Cifsd
cifsd kernel server(SMB/CIFS server)
Stars: ✭ 76 (-94.94%)
Mutual labels:  server, performance
Laravel S
LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.
Stars: ✭ 3,479 (+131.78%)
Mutual labels:  server, performance
Akarin
Akarin is a powerful (not yet) server software from the 'new dimension'
Stars: ✭ 332 (-77.88%)
Mutual labels:  server, performance

Venice

Swift License Slack Travis Codecov Codebeat Documentation

Venice provides structured concurrency and CSP for Swift.

Features

  • Coroutines
  • Coroutine cancelation
  • Coroutine groups
  • Channels
  • Receive-only channels
  • Send-only channels
  • File descriptor polling

Venice wraps a fork of the C library libdill.

Installation

Before using Venice you need to install our libdill fork. Follow the instruction for your operating system.

macOS

On macOS install libdill using brew.

brew install zewo/tap/libdill

Linux

On Linux we have to add our apt source first. You only need to run this command once in a lifetime. You don't need to run it again if you already have.

echo "deb [trusted=yes] http://apt.zewo.io ./" | sudo tee -a /etc/apt/sources.list
sudo apt-get update

Now just install the libdill apt package.

sudo apt-get install libdill

Add Venice to Package.swift

After installing libdill just add Venice as a dependency in your Package.swift file.

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/Zewo/Venice.git", majorVersion: 0, minor: 19)
    ]
)

Test Coverage

Coverage Sunburst

The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is represented by the number of statements and the coverage, respectively.

Documentation

You can check the Venice API reference for more in-depth documentation.

Structured Concurrency

Structured concurrency means that lifetimes of concurrent functions are cleanly nested. If coroutine foo launches coroutine bar, then bar must finish before foo finishes.

This is not structured concurrency:

Not Structured Concurrency

This is structured concurrency:

Structured Concurrency

The goal of structured concurrency is to guarantee encapsulation. If the main function calls foo, which in turn launches bar in a concurrent fashion, main will be guaranteed that once foo has finished, there will be no leftover functions still running in the background.

What you end up with is a tree of coroutines rooted in the main function. This tree spreads out towards the smallest worker functions, and you may think of this as a generalization of the call stack — a call tree, if you will. In it, you can walk from any particular function towards the root until you reach the main function:

Call Tree

Venice implements structured concurrency by allowing you to cancel a running coroutine.

let coroutine = try Coroutine {
    let resource = malloc(1000)
    
    defer {
        free(resource)
    }
    
    while true {
        try Coroutine.wakeUp(100.milliseconds.fromNow())
        print(".")
    }
}

try Coroutine.wakeUp(1.second.fromNow())
coroutine.cancel()

When a coroutine is being canceled all coroutine-blocking calls will start to throw VeniceError.canceledCoroutine. On one hand, this forces the function to finish quickly (there's not much you can do without coroutine-blocking functions); on the other hand, it provides an opportunity for cleanup.

In the example above, when coroutine.cancel is called the call to Coroutine.wakeUp inside the coroutine will throw VeniceError.canceledCoroutine and then the defer statement will run, thus releasing the memory allocated for resource.

Threads

You can use Venice in multi-threaded programs. However, individual threads are strictly separated. You may think of each thread as a separate process.

In particular, a coroutine created in a thread will be executed in that same thread, and it will never migrate to a different one.

In a similar manner, a handle, such as a channel or a coroutine handle, created in one thread cannot be used in a different thread.

License

This project is released under the MIT license. See LICENSE for details.

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