From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UiOqT-0001cw-RI for bitcoin-development@lists.sourceforge.net; Fri, 31 May 2013 12:54:13 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.212.174 as permitted sender) client-ip=209.85.212.174; envelope-from=andyparkins@gmail.com; helo=mail-wi0-f174.google.com; Received: from mail-wi0-f174.google.com ([209.85.212.174]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1UiOqT-0001sp-1m for bitcoin-development@lists.sourceforge.net; Fri, 31 May 2013 12:54:13 +0000 Received: by mail-wi0-f174.google.com with SMTP id c10so658693wiw.7 for ; Fri, 31 May 2013 05:54:06 -0700 (PDT) X-Received: by 10.180.37.229 with SMTP id b5mr3165679wik.29.1370004846932; Fri, 31 May 2013 05:54:06 -0700 (PDT) Received: from momentum.localnet ([91.84.15.31]) by mx.google.com with ESMTPSA id en3sm3832021wid.1.2013.05.31.05.54.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 May 2013 05:54:06 -0700 (PDT) From: Andy Parkins To: bitcoin-development@lists.sourceforge.net Date: Fri, 31 May 2013 13:54:03 +0100 User-Agent: KMail/1.13.7 (Linux/3.8-trunk-686-pae; KDE/4.8.4; i686; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <201305311354.03625.andyparkins@gmail.com> X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (andyparkins[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1UiOqT-0001sp-1m Subject: Re: [Bitcoin-development] Implementing batch processing for -blocknotify X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 May 2013 12:54:14 -0000 On Friday 31 May 2013 12:56:43 Rune Kj=E6r Svendsen wrote: > I have an application that wants to keep up with new blocks as they come > in. For that I can use the -blocknotify option with bitcoind, which will > execute my application for each new block. >=20 > The problem is that my app isn't necessarily quick enough to finish its > work before a new block comes in and the app is executed again. This means > the that bitcoind might keep executing my application even though the > previous instance hasn't finished, and that's fairly inefficient > resource-wise, as many instances of the application will be running > simultaneously. Have your program try to create a unix-domain socket when it starts. If it= =20 can't create it (because one already exists at that path), then connect to = it. You then have two modes: - Creator of socket, listens to socket for more incoming data, and adds it= to some sort of internal block queue. - Client to socket, pushes output of -blocknotify to socket and exits Your concurrency problems go away because only one process is ever actually= =20 doing something with the data. Should be fairly straight forward. The client is simple. The server is tw= o=20 threads, one listening on the socket and then briefly locking and updating = a=20 queue, and one thread briefly locking and removing from the queue. Andy =2D-=20 Dr Andy Parkins andyparkins@gmail.com