[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How absurd is this?

khaines

8/11/2006 7:18:00 PM

3 Answers

Martin DeMello

8/11/2006 7:28:00 PM

0

On 8/12/06, khaines@enigo.com <khaines@enigo.com> wrote:
> Imagine you have in a method a block. Sometimes you will want that block
> to be executed via a mutex.synchronize() call. And sometimes you don't
> want to synchronize.

I'd add a Mutex#synchronize_unless

def method_with_a_block
@mutex.synchronize_unless(dont_lock_here()) do
puts "This block may or may not be synchronized, depending on whether
dont_lock_here() returned true or false."
end
end

martin

Mike Harris

8/11/2006 7:37:00 PM

0

Martin DeMello wrote:

> On 8/12/06, khaines@enigo.com <khaines@enigo.com> wrote:
>
>> Imagine you have in a method a block. Sometimes you will want that
>> block
>> to be executed via a mutex.synchronize() call. And sometimes you don't
>> want to synchronize.
>
>
> I'd add a Mutex#synchronize_unless
>
> def method_with_a_block
> @mutex.synchronize_unless(dont_lock_here()) do
> puts "This block may or may not be synchronized, depending on
> whether
> dont_lock_here() returned true or false."
> end
> end
>
> martin
>
>
+1

khaines

8/11/2006 7:45:00 PM

0