Created
July 17, 2012 15:19
-
-
Save Watson1978/3130031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# MacRuby - Dispatch::Source のサンプル | |
# 変更を監視するファイル | |
path = File.expand_path "~/test.txt" | |
gcdque = Dispatch::Queue.new('sample') | |
gcdsem = Dispatch::Semaphore.new(0) | |
fmask = Dispatch::Source::VNODE_DELETE | Dispatch::Source::VNODE_WRITE | |
io = File.open(path, "w") | |
Dispatch::Source.new(Dispatch::Source::VNODE, | |
io, | |
fmask, | |
gcdque) do |s| | |
puts "changed" | |
gcdsem.signal | |
end | |
gcdsem.wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment