Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Coming IO features in Tango

(Locked) Moderators: sean kris larsivi

Posted: 06/22/07 21:20:35 Modified: 06/26/07 21:06:23

To make the Tango development process more transparent, we will start announcing new and coming features outside of the release cycle itself. This may be important changes to Tango, notable feature additions or particularly exciting compatible libraries. They will be about features already near-finished or well on the way, to avoid false pretences.

By popular demand, the Tango IO subsystem now exposes a 'stream' oriented API which will be available in the upcoming release 0.99. Tango streams are described by InputStream and OutputStream, which are hosted by the existing Conduit mechanism. Both input and output support the notion of 'filter' chains: distinct chains of attached streams to manipulate content as it flows in one direction or the other. In order to avoid the pitfalls of a purely Decorator-pattern design, these stream chains are fully encapsulated within the hosting Conduit -- this allows the specific attributes of a Conduit (such as file seek, or various socket attributes) to be exposed at all times, instead of trying to force-fit those options into the stream itself. Thus, streams retain an uncomplicated API with little more than read, write, copy and flush operations.

Tango has been adjusted in various ways to take advantage of the new streams, and we'll see further use of that model in later releases.

Further on, we're building an asynchronous I/O library based on Tango's IO abstractions with notifications sent on completion of I/O events. The plan for the first stage of development is to have an API capable of delivering I/O, timer and (possibly) Unix signal events to applications through delegates. It will be able to efficiently handle large numbers ( i.e. thousands) of active file descriptors/handles (sockets, pipes, etc.) on all the platforms that Tango supports. Initially the library will work both on Windows (using I/O completion ports) and on Linux (using epoll); we will then provide a Mac OS X and FreeBSD implementation (based on kqueue), and other platforms if there is enough interest from the community.

During the second stage of development we will build a framework on top of the asynchronous I/O library that will be able to multiplex I/O jobs using Tango Fibers (i.e. lightweight or userspace threads). Each fiber waiting for I/O events will be suspended until the event is received, helping to avoid consuming excessive resources. The load from each fiber will be distributed among a pool of threads.

The idea behind both libraries is to be able to efficiently implement network protocols that are either synchronous (HTTP, SMTP, etc.) and asynchronous (XMPP, etc.) in nature in both client and server applications.

There are no responses to display.