From: Eric Wong Date: 2011-03-15T04:58:41+09:00 Subject: [ruby-core:35499] Re: [Ruby 1.9 - Bug #4463][Open] [PATCH] release GVL for fcntl() for operations that may block Eric Wong wrote: > KOSAKI Motohiro 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