Eric Wong <normalperson / yhbt.net> wrote:
> KOSAKI Motohiro <kosaki.motohiro / gmail.com> wrote:
> > Umm..
> > I don't like its interface so much. your flock object don't mange any lock
> > state. it's merely wrapper of argument of fcntl. your interface mean we need
> > two line every lock operation. eg.
> 
> That would allow us to do something stateful like:
> 
> 	Fcntl.synchronize(io, :WRLCK, :SET, 0, 0) do
> 	  # ...
> 	end

Following up, I went with something along these lines here.

http://redmine.ruby-lang.org/issues/4464
http://redmine.ruby-lang.org/attachments/1540/0001-add-Fcntl-Lock-object-for-easier-use-of-POSIX-file-l.patch

Simple use case to lock the whole file is just:

  Fcntl::Lock.synchronize(file) do
    # ...
  end

-- 
Eric Wong