# HG changeset patch # User jittat # Date 2009-04-27 14:08:37 # Node ID a8ad25e1c3fce18e28d6ce59440cb16fada21818 # Parent 60ec4e2c595338f20c8c7fd3590bc6ce457213a5 added more comments on dir_init.rb git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@383 6386c4cd-e34a-4fa8-8920-d93eb39b512e diff --git a/judge/scripts/lib/dir_init.rb b/judge/scripts/lib/dir_init.rb --- a/judge/scripts/lib/dir_init.rb +++ b/judge/scripts/lib/dir_init.rb @@ -12,6 +12,25 @@ # This library maintain a reference counter on the processes using the # directory. It locks the dir to manage critical section when # updating the reference counter. +# +# Example usage: +# +# dman = DirInit::Manager.new("mydir") +# +# dman.setup do +# # do some initialization +# end +# +# #... do anything you want +# +# dman.teardown do +# # clean up +# end +# +# DirInit::Manager ensures that the block passed to setup +# only runs once by the first process in the concurrent dir usage and +# block passed to teardown runs once by the last process in +# that concurrent activities leaving that dir. module DirInit