Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Created July 17, 2012 15:19
Show Gist options
  • Save Watson1978/3130031 to your computer and use it in GitHub Desktop.
Save Watson1978/3130031 to your computer and use it in GitHub Desktop.
# -*- 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