[Rake-devel] @lock.synchronize

Ittay Dror ittay.dror at gmail.com
Sat Dec 6 16:21:18 EST 2008


Hi,


I wanted to share my findings about @lock.synchronize, used in 
invoke_with_call_chain.


This method is implemented as

def mon_synchronize
  mon_enter
  begin
    yield
  ensure
    mon_exit
  end
end


The downside here is that creating a block requires resources and since 
the body of this particular block creates a potentially large recursion 
(esp. in Buildr), this can end up waisting a lot of memory. In my case, 
replacing:
@lock.synchronize do
   ...
end

with
begin
   @lock.mon_enter
    ....
ensure
   @lock.mon_exit
end

made the difference between a segmentation fault and a successful build.

ittay

-- 
--
Ittay Dror <ittay.dror at gmail.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rake-devel/attachments/20081206/d8aedbaf/attachment.html>


More information about the Rake-devel mailing list