From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6939 64.71.128.0/18 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.posix-mq.general Subject: [RFC] try* interfaces in posix_mq 0.8.0pre Date: Sun, 27 Feb 2011 11:26:12 +0000 Message-ID: <20110227112612.GA23802@dcvr.yhbt.net> References: <20110227112612.GA23802@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1298805993 3770 80.91.229.12 (27 Feb 2011 11:26:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 27 Feb 2011 11:26:33 +0000 (UTC) To: ruby.posix.mq@librelist.org Original-X-From: ruby.posix.mq@librelist.org Sun Feb 27 12:26:29 2011 Return-path: Envelope-to: gclrpg-ruby.posix.mq@m.gmane.org In-Reply-To: <20110227112612.GA23802@dcvr.yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: ruby.posix.mq@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.posix-mq.general:75 Archived-At: Received: from zedshaw.xen.prgmr.com ([64.71.167.205]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ptelb-0005GQ-CR for gclrpg-ruby.posix.mq@m.gmane.org; Sun, 27 Feb 2011 12:26:28 +0100 Received: from zedshaw.xen.prgmr.com (localhost [IPv6:::1]) by zedshaw.xen.prgmr.com (Postfix) with ESMTP id 45C9821C505 for ; Sun, 27 Feb 2011 11:26:19 +0000 (UTC) I just pushed this out to RubyGems.org (and ruby_posix_mq.git). Let us know what you think, thanks! posix_mq 0.8.0pre - kinder, gentler and less exceptional This adds trysend, tryreceive, and tryshift interfaces to avoid exceptions on common EAGAIN errors for non-blocking users. EAGAIN during non-blocking messages is common when there are multiple readers/writer threads/processes working on the same queue. trysend is like send, except it returns true for success and false for EAGAIN. send (still) returns nil, which I now consider a mistake but won't change until post-1.0... tryreceive and tryshift are like receive and shift respectively, but they return nil for EAGAIN and the same return values for their non-shift variants. None of these methods call mq_setattr() beforehand to set the non-blocking flag, it assumes the user set it once before they were ever called and never changes it. Checking/setting the non-blocking flag every time is needless overhead and still subject to race conditions if multiple processes/queues keep flipping flag on the same queue descriptor. These interfaces are not yet final, feedback is appreciated at ruby.posix.mq@librelist.org. -- Eric Wong