当前位置: 首页 > 软件库 > 程序开发 > 网络工具包 >

popol

Minimal non-blocking I/O for Rust
授权协议 MIT License
开发语言 C/C++
所属分类 程序开发、 网络工具包
软件类型 开源软件
地区 不详
投 递 者 严亦
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

popol

Minimal non-blocking I/O for Rust.

See examples/ folder for usage.

Overview

Async I/O in Rust is still an unsolved problem. With the stabilization ofasync/await, we are seeing a number of libraries and runtimes crop up, suchas async-std and smol, while others such as tokio and mio are maturing.The problem with async/await is that you can't use any of the standardlibrary traits, such as Read and Write. The async ecosystem comes with anentirely separate suite of traits (eg. AsyncRead and AsyncWrite) and I/Olibraries. Furthermore, most of these runtimes have a large dependencyfootprint, partly from having to provide async alternatives to the standardlibrary functions, and partly due to the complexity of these runtimes.

What do we need? For most use-cases, the ability to handle between a dozenand up to a few hundred open connections without blocking, is all we need.This places us squarely within the territory of the venerable poll() function,which is available on almost all platforms.

Popol is designed as a minimal ergonomic wrapper around poll(), built forpeer-to-peer networking.

By building on poll, we have the following advantages:

  • Much smaller implementation than even the smallest async/await runtimes
  • All of the Rust standard library just works (io::Read, io::Write, etc.)
  • Virtually zero-dependency (the libc crate is the only dependency)
  • No "runtime". Keeps the code much easier to reason about

Why not use epoll? A couple of reasons:

  1. It is more complex than poll and requires us to write more code
  2. It isn't portable (only works on Linux)
  3. poll is sufficient for handling most workloads

Compared to mio, popol is:

  • A lot smaller (about 10% of the size)
  • A little more flexible and easy to use
  • Supports standard library sockets
  • Currently focused on unix-based system compatibility

Some of the advantages of popol's API over mio's:

  • popol supports multiple wakers per wait call.
  • popol event source identifiers are not limited to u64.
  • popol's API is composed mostly of infallible functions.

On the other hand, mio is more mature and probably better at handling verylarge number of connections. Mio also currently supports more platforms.

License

This software is licensed under the MIT license. See the LICENSE file fordetails.

About

(c) Alexis Sellier https://cloudhead.io

  • 文章类 Rust 模块系统的超清晰解释 Rust 的模块系统可能对于新人来说有些困惑,这篇文章通过几个循序渐进的小例子,让你快速且清晰的对 Rust 模块系统有一个基本的认识. http://www.sheshbabu.com/posts/rust-module-system/ 使用 Rust 实现 boids 算法 (Game) 这是 Rust 来实现经典的 Boids 算法的一系列文章的 Pa

相关阅读

相关文章

相关问答

相关文档