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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 95411BBAF for ; Sat, 17 Jul 2010 16:20:24 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuoFAO5YQUzV+668/2dsb2JhbACTNo0pvziFJQQ X-IronPort-AV: E=Sophos;i="4.55,219,1278280800"; d="scan'208";a="63958391" Received: from rastageeks.org (HELO mail.rastageeks.org) ([213.251.174.188]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 17 Jul 2010 16:20:24 +0200 Received: from leonard.localnet (ip-102.34.99.216.dsl-cust.ca.inter.net [216.99.34.102]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.rastageeks.org (Postfix) with ESMTPSA id 9DDDF45EF5; Sat, 17 Jul 2010 16:31:05 +0200 (CEST) From: Romain Beauxis To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Smart ways to implement worker threads Date: Sat, 17 Jul 2010 10:20:58 -0400 User-Agent: KMail/1.13.3 (Linux/2.6.32-4-amd64; KDE/4.4.4; x86_64; ; ) Cc: Goswin von Brederlow References: <87sk3mcaeq.fsf@frosties.localdomain> <87hbjy77vk.fsf@frosties.localdomain> In-Reply-To: <87hbjy77vk.fsf@frosties.localdomain> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201007171020.58902.toots@rastageeks.org> X-Spam: no; 0.00; syscalls:01 threads:01 threads:01 terminate:01 caml-list:01 modules:02 complex:05 implement:06 ecrit:06 thread:06 thread:06 queue:07 queue:07 broadcast:92 function:08 Le samedi 17 juillet 2010 05:52:31, Goswin von Brederlow a =E9crit : > Now I have a queue that I can include in select. The take function can > be used by the worker threads. The main thread can use either take_all > or process to save on syscalls or stick with take to ensure the queue > does not starve the other FDs. >=20 > Also I think I can use the EventFD to terminate a queue and wake up all > listeners. Closing the EventFD should wake up any thread stuck in read > and prevent any threads from becoming stuck in the future. Haven't > tested that yet though. I don't see why you want to use EventFD and not Condition.wait/signal. In=20 particular, Condition.broadcast does exactly the last thing you mention. Now, I don't understand why you asked for related modules and and the end=20 discard all of them and post your own implementation. Your issue is not tha= t=20 complex you could have done that in the first place... Romain