Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17354

Re: Make a small function thread safe

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tim.wintle@teamrubber.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.98; '*S*': 0.01; 'brad': 0.07; 'x-mailer:evolution 2.28.3': 0.07; 'instance.': 0.09; 'module)': 0.09; 'unsigned': 0.09; 'void': 0.15; '107': 0.16; 'subject:function': 0.16; 'threading': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'header :In-Reply-To:1': 0.22; 'cc:2**0': 0.24; '(see': 0.28; 'skip:b 20': 0.29; 'cc:addr:python.org': 0.29; 'fri,': 0.34; 'header:Reply- To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:bethere.co.uk': 0.84; '111': 0.91; 'subject:Make': 0.96
Subject Re: Make a small function thread safe
From Tim Wintle <tim.wintle@teamrubber.com>
To Brad Tilley <kj4eit@gmail.com>
In-Reply-To <10d3d04f-1708-4942-8e69-92b715f01ff8@p20g2000vbm.googlegroups.com>
References <10d3d04f-1708-4942-8e69-92b715f01ff8@p20g2000vbm.googlegroups.com>
Content-Type text/plain; charset="UTF-8"
Organization Team Rubber
Date Fri, 16 Dec 2011 13:33:14 +0000
Mime-Version 1.0
X-Mailer Evolution 2.28.3
Content-Transfer-Encoding 7bit
X-SA-Exim-Connect-IP 87.194.110.230
X-SA-Exim-Mail-From tim.wintle@teamrubber.com
X-SA-Exim-Scanned No (on mail.netsight.co.uk); SAEximRunCond expanded to false
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To tim.wintle@teamrubber.com
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3726.1324044351.27778.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324044351 news.xs4all.nl 6980 [2001:888:2000:d::a6]:60634
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17354

Show key headers only | View raw


On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote:
> 107         void increment_counter( unsigned int& counter )
> 108         {
> 109                 boost::mutex::scoped_lock lock( counter_lock );
> 110                 ++counter;
> 111         }


with counter_lock:
    counter += 1


... where counter_lock is a threading.Lock instance.

(see docs for the threading module)

Tim

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Make a small function thread safe Brad Tilley <kj4eit@gmail.com> - 2011-12-16 05:21 -0800
  Re: Make a small function thread safe Tim Wintle <tim.wintle@teamrubber.com> - 2011-12-16 13:33 +0000
  Re: Make a small function thread safe Tim Wintle <tim.wintle@teamrubber.com> - 2011-12-16 14:36 +0000
    Re: Make a small function thread safe Brad Tilley <kj4eit@gmail.com> - 2011-12-16 07:05 -0800
  Re: Make a small function thread safe Lie Ryan <lie.1296@gmail.com> - 2011-12-17 09:08 +1100
    Re: Make a small function thread safe John Nagle <nagle@animats.com> - 2011-12-16 18:18 -0800
      Re: Make a small function thread safe RangerElf <gustavo.cordova@gmail.com> - 2011-12-18 00:52 -0800
        Re: Make a small function thread safe Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-18 23:57 -0700
  Re: Make a small function thread safe ting@thsu.org - 2011-12-19 15:56 -0800

csiph-web