Version franaise
Home About Download Resources Contact us
Browse thread
[ANN] coThreads 0.10
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Zheng Li <li@p...>
Subject: Re: [ANN] coThreads 0.10

Hi,

First note that the naming convention follows the standard threads library in
OCaml: Threads and coThreads (both with 's') refer to the library (*.cm(x)a);
Thread and Cothread (neither with 's') are modules (*.cm[ox]) inside.

skaller <skaller@users.sourceforge.net> writes:
>> The Thread module interfaces from the three engines differ with each
>> other! Note that this is not the problem from coThreads, it's a problem of
>> standard Threads library:
>
> Why don't you just use a different module name?
The different module name *is* Cothread, a compatible super set of Thread
module. Use this module instead if you want to have object-level
compatibility. In short, all the three engines have the two libraries with
isomorphic structures (quite simple) :

<code>
  threads.cm(x)a = threads.cm[ox], mutex.cm[ox], condition.cm[ox], event.cm[ox]
cothreads.cm(x)a = threads.cm[ox], mutex.cm[ox], condition.cm[ox], event.cm[ox], cothread.cm[ox], stm.cm[ox]
</code>

See, we also provide the compatible "threads.cm(x)a" for the process
engine. Think about the following scenario:

 - If you're working on legacy code, you don't care STM and don't care
   object-level compatibility, the only thing you're interested is to running
   your code with process to speedup, then the only thing to change in your
   Makefile is the include path e.g. "-I +threads" -> "-I +process", you can
   still using Thread module and "threads.cma", they are present in process
   engine.

 - You have several projects, some of them using traditional Threads, some
   using coThreads, you don't want to bother to remember that. So simply
   changing all linking library from threads.cma to cothreads.cma is fine,
   because coThreads library contains every modules in Threads library.

 - You have some legacy code written in standard Threads, and you'd like to
   have it run with processes. Though you don't care about the newly introduced
   modules of coThreads, you do want to have a single copy of object files for
   each engines. In such case, you need to add one line to any source code
   which makes use of the Thread module:

   module Thread = Cothread

   because Thread module (the only module in Threads and coThreads) don't have
   object-level compatibility, and change any occurrence of “threads.cm(x)a” to
   “cothreads.cm(x)a” in your Makefile. 

For more explanation, see http://cothreads.sourceforge.net/doc/compatibility

-- 
Zheng Li
http://www.pps.jussieu.fr/~li