mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
42eeb2c1b1
commit
01e9a7be61
1 changed files with 8 additions and 5 deletions
13
file.c
13
file.c
|
@ -3499,15 +3499,18 @@ rb_thread_flock(void *data)
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* # write lock
|
* # update a counter using write lock
|
||||||
* # don't use "w" because it truncates the file before lock.
|
* # don't use "w" because it truncates the file before lock.
|
||||||
* File.open("testfile", File::WRONLY|File::CREAT, 0644) {|f|
|
* File.open("counter", File::RDWR|File::CREAT, 0644) {|f|
|
||||||
* f.flock(File::LOCK_EX)
|
* f.flock(File::LOCK_EX)
|
||||||
* f.truncate(0)
|
* value = f.read.to_i + 1
|
||||||
* f.write "new content"
|
* f.rewind
|
||||||
|
* f.write("#{value}\n")
|
||||||
|
* f.flush
|
||||||
|
* f.truncate(f.pos)
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* # read lock
|
* # read the counter using read lock
|
||||||
* File.open("testfile", "r") {|f|
|
* File.open("testfile", "r") {|f|
|
||||||
* f.flock(File::LOCK_SH)
|
* f.flock(File::LOCK_SH)
|
||||||
* p f.read
|
* p f.read
|
||||||
|
|
Loading…
Reference in a new issue