<HTML dir=ltr><HEAD><TITLE>Re: [asterisk-dev] Astobj2 and locks</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6000.16525" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText4172 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>OK, that makes sense. I was under the impression the lock was required for any kind of change. But we're most concerned the rug being pulled out from underneath us then.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Thanks for the explanation.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>- Brad</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT size=2><BR>><BR>> Do I have it all wrong somehow? And if so, please educate me as to how<BR>> so that I may be enlightened.<BR><BR>It comes down to understanding exactly when and why the locking is required. In<BR>some places in Asterisk, locks are used (and sometimes abused) to ensure that<BR>the object we're looking at doesn't disappear. However, in this case, the<BR>object has a reference count, and we currently hold a reference, so we know that<BR>it will not disappear.<BR><BR>The lock for the member struct is still required in some situations, when you<BR>need to protect certain elements of the member from changing while you're<BR>working with them. In this case, there is no possibility for something to<BR>change in the member that could cause this code to break. Thus, no locking is<BR>required.<BR><BR>--<BR>Russell Bryant<BR>Software Engineer<BR>Digium, Inc.<BR><BR>_______________________________________________<BR><BR>Sign up now for AstriCon 2007! September 25-28th. <A href="http://www.astricon.net/">http://www.astricon.net/</A><BR><BR>--Bandwidth and Colocation Provided by <A href="http://www.api-digital.com--/">http://www.api-digital.com--</A><BR><BR>asterisk-dev mailing list<BR>To UNSUBSCRIBE or update options visit:<BR> <A href="http://lists.digium.com/mailman/listinfo/asterisk-dev">http://lists.digium.com/mailman/listinfo/asterisk-dev</A><BR><BR></FONT></DIV></BODY></HTML>