From: "Avdi B. Grimm" Date: 2002-01-18T01:07:09+09:00 Subject: Threading and the ACE Libraries I have to say, all this discussion on threading has been wonderfully illuminating. Thanks to everyone who took the time to comment. It ocurred to me while reading these messages, that my own experience with threads has been colored more than I realized by the middleware I'm using. I was introduced to thread and socket programming via the ACE libraries. For those who haven't heard of ACE, let me briefly describe (BTW, I'm not associated with ACE; I'm just a contented user): ACE is a set of open-source cross-platform C++ libraries for multithreaded network programming. At it's lowest level, ACE consists of a set of wrapper functions that abstract the many different OS APIs into a single, consistent, POSIX-like API. On top of that is built a number of higher-level classes which implement useful patterns like Acceptor-Connector, Reactor, Task, Active Object, and many others. Because of it's widespread use and it's support of so many platforms, ACE is probably the closest thing that C++ has to a standard networking and threading API. It's also an excellent case study in pattern discovery, documentation, and implementation. Doug Schmidt wrote a book, "Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects" (aka POSA2) based on the patterns discovered and codified during the creation of ACE. It's because of the ACE libraries that I believe that thread coding doesn't have to be as nonportable and difficult as so many seem to think. With the right middleware, thread programming can be quite easy. Applications can be completely event-driven. Or they can be composed of autonomous active objects, each encapsulating it's own thread of execution, safely and transparently turning asynchronous method calls into internally queued commands which are then executed synchronously. All without the programmer having to work out the details of synchronization. I'd recommend anyone who's interested in multithreaded programming to take a look at some of the papers on the ACE website (http://www.cs.wustl.edu/~schmidt/ACE.html), and perhaps read POSA2. I'm beginning to think that I should start working on a set of Ruby implementations of some of the patterns documented in POSA2. I don't know that I have the time; but I'd like to demonstrate what I've been talking about. Also, it's not to presumptious, might I suggest that Matz and whoever else is working on Ruby 2.0 take a look at ACE to see if it might be of any use in making Ruby's native threads portable? ACE is C++, of course, but it may be that the low-level wrapper functions are sufficiently close to C to be adapted for use in the Ruby kernel. It might save some of the work of porting Ruby to different platforms. - Avdi Grimm __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/