From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 71F51BBAF for ; Fri, 16 Jul 2010 06:23:21 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlgCAAp7P0zRVaG0mGdsb2JhbACDHpxFCBUBAQEBAQgJDAcRIq1UO4IPhV0uiFMBAQMFhC1yBIN+hFI X-IronPort-AV: E=Sophos;i="4.55,212,1278280800"; d="scan'208";a="66520229" Received: from mail-gx0-f180.google.com ([209.85.161.180]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Jul 2010 06:23:21 +0200 Received: by gxk22 with SMTP id 22so1406210gxk.39 for ; Thu, 15 Jul 2010 21:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=2/dKzTDKbTeaueZImwbO2C5hDhH/HFcfDqCnFYmxMRc=; b=KVrvvh6BOY+REkXVD4EWRQcMT+vp52kbiQ5NTZ7JnKL5i1ARFU+i+5/LhDYeI5r+j1 3sCQuDI0S6QWcPbcPCTRjgptTVyHYWfl6ilCheRfPfRj5tDGk6Gdjlw6Obd34W+sWvpx IXPwdz4u0mk/KbgyZlA1twNxDgdGZtfnVs+2g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=L6jtlm9DjoEWEt864hH79S8fyaHA/tRLpTuKh6XDO4Mx36OaaRjUkM9sriL5vnQub8 puqresuE8sOdduN4wWSuCfCypwTzWJNluTMvzl2p+GZ9dsjpnBgr1P6H8yGjS9h0rmNt uSfp0sJs7UFoMst6knd3UiUko1qgCykS2EGcE= MIME-Version: 1.0 Received: by 10.101.145.40 with SMTP id x40mr644674ann.261.1279254199738; Thu, 15 Jul 2010 21:23:19 -0700 (PDT) Received: by 10.100.212.6 with HTTP; Thu, 15 Jul 2010 21:23:19 -0700 (PDT) In-Reply-To: <87hbk0vzut.fsf@frosties.localdomain> References: <87sk3mcaeq.fsf@frosties.localdomain> <87zkxsfvsg.fsf@frosties.localdomain> <87hbk0vzut.fsf@frosties.localdomain> Date: Thu, 15 Jul 2010 23:23:19 -0500 Message-ID: Subject: Re: [Caml-list] Smart ways to implement worker threads From: Rich Neswold To: Goswin von Brederlow Cc: caml-list@yquem.inria.fr Content-Type: multipart/alternative; boundary=0016e6d433ae272107048b799484 X-Spam: no; 0.00; reppy:01 reppy:01 threads:01 threads:01 wrote:01 wrote:01 caml-list:01 writes:01 writes:01 chapters:02 chapters:02 primitive:02 primitive:02 constructs:02 constructs:02 X-Attachments: cset="UTF-8" cset="UTF-8" --0016e6d433ae272107048b799484 Content-Type: text/plain; charset=UTF-8 On Thu, Jul 15, 2010 at 11:02 PM, Goswin von Brederlow wrote: > Rich Neswold writes: > > Thanks. That is about what I got so I do seem to understand the > differences right. > > For my use case this would then come down to implement solution 3 with > channels instead of my own queues. Well, channels are thread safe queues > just by another name. I think I see now how they make the code simpler > to write. > Channels are a thread-safe communication channel of depth one (i.e. you can only pass one item at a time.) The channel is a primitive that allows reliable synchronized communication between threads. The Reppy book describes in later chapters how to use the channel primitive to build up queues and other, more complicated constructs (like RPCs and multicasting to many processes.) In fact, you might use the RPC ideas to pass your checksumming requests to worker tasks and receive the results. -- Rich Google Reader: https://www.google.com/reader/shared/rich.neswold Jabber ID: rich@neswold.homeunix.net --0016e6d433ae272107048b799484 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Jul 15, 2010 at 11:02 PM, Goswin von Brederlow &l= t;goswin-v-b@web.de> wro= te:
Rich Neswold <rich.neswold@gmail.com> writes:

Thanks. That is about= what I got so I do seem to understand the
differences right.

For my use case this would then come down to implement solution 3 with
channels instead of my own queues. Well, channels are thread safe queues just by another name. I think I see now how they make the code simpler
to write.

Channels are a thread-safe= =C2=A0communication=C2=A0channel of depth one (i.e. you can only pass one i= tem at a time.) The channel is a primitive that allows reliable synchronize= d communication between threads. The Reppy book describes in later chapters= how to use the channel primitive to build up queues and other, more compli= cated constructs (like RPCs and multicasting to many processes.)

In fact, you might use the RPC ideas to pass your checksumming req= uests to worker tasks and receive the results.
--0016e6d433ae272107048b799484--