You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@buildr.apache.org by Ittay Dror <it...@gmail.com> on 2008/12/06 22:21:18 UTC

@lock.synchronize

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 <it...@gmail.com>