@lock.synchronize

View: New views
1 Messages — Rating Filter:   Alert me  

@lock.synchronize

by Ittay Dror :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>