Build Status Build status

About

The libasync asynchronous library is written completely in D, features a cross-platform event loop and enhanced connectivity and concurrency facilities for extremely lightweight asynchronous tasks. It embeds naturally to D projects (DMD >= 2.067.0, LDC >= 0.15.1), compiles statically with your project and has an open source license (MIT).

A fully functional, tested vibe.d driver is available in the latest version of vibe.d, you can enable it by appending "subConfigurations": { "vibe-d": "libasync"} in your project's dub.json configuration file.

Features

The following capabilities are now being tested and should not be used in any circumstance in a production environment.

(*) Unit tests confirmed on Mac, Linux, Windows - Platforms used were Mac OS X (10.8, 10.9), Linux (Fedora 20+) and Windows 32/64 bit, although it should be compatible to 99% of Desktop OS users.

(*) Compiles with DMD & LDC (DMD 2.067.0, 2.067.1, LDC 0.15.1)

  • Multi-threading support - EventLoop can be launched and run from an unlimited number of threads!

  • Asynchronous TCP connection - handles multiple requests at a time in each individual thread

  • Buffered TCP connection - Allows callbacks to be attached to a byte sized future

  • Asynchronous TCP listener - delivers a new connection to the delegate of your choice

  • File Operations - executes file read/write/append commands in a thread pool, notifies of completion in a handler

  • DNS resolver - runs blocking DNS resolve operations in a thread pool, savings are the duration of a ping.

  • File/Folder Watcher - watches directories for file changes (CREATE, DELETE, MODIFY, RENAME/MOVE)

  • UDP connection - receives or sends packets from/to multiple peers

  • Timer - sets a periodic or one-shot/periodic timer with high-precision (μs) to call a select delegate

  • Signal - Wakes up the event loop in a foreign thread and passes a message to its delegate

  • Notifier - Thread-local and lock-less adaptation of Signal which queues a message intended for a local delegate

Limitations

Some or all of these limitations are possibly being implemented currently and may be available in a future release.

  • One EventLoop per thread - There is a hard limit of one event loop per thread
  • Manual error management - The entire library is nothrow and error management must be built on top of it.
  • No embedded HTTP or TLS handlers - The support fort HTTP, TLS (and other protocols) is only available through vibe.d with Tasks as of yet.

Installation Instructions

  • Download and install DMD 2.067.0+ from dlang.org
  • Download and install dub 0.9.22+ from code.dlang.org
  • Use Git to clone this repository
  • Run dub test to test the library on your operating system (submit any issue with a log report by uncommenting enum LOG = true in types.d)
  • Add the library to your project by including it in the dependencies, using import libasync
  • The recommended editor is MonoDevelop with Mono-D due to its Mixin Template resolver (must be enabled manually), with auto-completion and comment-resolved summary tooltips.
  • On another note, you can also try the vibe.d libasync built-in driver by adding "subConfigurations": { "vibe-d": "libasync" } to your vibe.d dub.json.

Tutorial

There are 4 examples available at the moment, they are located in examples/. They must be tested by starting the server before the client.

All other usage examples are available in source/libasync/test.d.

Documentation has been written throughout the code.



建立状态

关于

libasync异步库完全写在D中,具有跨平台事件循环和增强的连接性和并发功能,适用于非常轻量级的异步任务。它自然嵌入到D项目(DMD> = 2.067.0,LDC> = 0.15.1),与您的项目静态编译并具有开源许可证(MIT)。

可以在最新版本的vibe.d 中使用功能全面的vibe.d驱动程序,您可以通过在项目的dub.json配置文件中附加subConfigurations:{vibe-d:libasync} 来启用它。

功能

以下功能现在正在测试中,不应在生产环境中的任何情况下使用。

Mac OS X(10.8,10.9),Linux(Fedora 20+)和Windows 32/64位平台使用的平台虽然在Mac,应兼容99%的桌​​面操作系统用户。

(*)与DMD& LDC (DMD 2.067.0,2.067.1,LDC 0.15.1)

  • 多线程支持 - EventLoop可以从无限数量的线程启动并运行!

  • 异步TCP连接 - 在每个线程

    中一次处理多个请求
  • 缓冲TCP连接 - 允许将回调附加到未来字节大小的

  • 异步TCP侦听器 - 提供与您选择的代理的新连接

  • 文件操作 - 在线程池中执行文件读/写/追加命令,在处理程序中通知完成

  • DNS解析器 - 在线程池中运行阻止DNS解析操作,节省ping的持续时间。

  • 文件/文件夹观察器 - 查看文件更改的目录(CREATE,DELETE,MODIFY,RENAME / MOVE)

  • UDP连接 - 从/到多个对等体接收或发送数据包

  • 定时器 - 设置具有高精度(μs)的周期性或单触发/周期性定时器来调用选择委托

  • 信号 - 唤醒外部线程中的事件循环,并将消息传递给其委托

  • 通知程序 - 针对本地委托的消息排队的信号

    的线程本地和无锁定适应

限制

这些限制中的一些或全部可能正在实施中,可能在将来的版本中可用。

  • 每个线程一个EventLoop - 每个线程有一个事件循环的硬限制
  • 手动错误管理 - 整个库都是 nothrow ,错误管理必须建立在其上。
  • 没有嵌入的HTTP或TLS处理程序 - HTTP,TLS(和其他协议)的支持仅可通过vibe.d与任务一起提供。

安装说明

  • dlang.org 下载并安装DMD 2.067.0+
  • code.dlang.org 下载并安装dub 0.9.22+
  • 使用Git克隆此存储库
  • 运行 dub test 来测试您的操作系统上的库(通过在 types.d中取消注释枚举LOG = true 来提交日志报告的任何问题。 / code>)
  • 使用 import libasync
  • 将库包含在依赖项中,将库添加到项目中
  • 推荐的编辑器是MonoDevelop,由于其Mixin Template解析器(必须手动启用),因此 Mono-D 具有自动完成和注释解析的摘要工具提示。
  • 另一个注意事项,您还可以通过在您的vibe.d dub中添加subConfigurations:{vibe-d:libasync} 来尝试vibe.d libasync内置驱动程序.json。

教程

目前有4个示例可用,它们位于 examples / 中。必须通过在客户端之前启动服务器来测试它们。

所有其他用法示例可以在 source / libasync / test.d 中找到。

整个代码中已经写入了文档。




相关问题推荐