トップ «前の日記(2014-01-10) 最新 次の日記(2014-01-12)» 編集

ヨタの日々

2001|08|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|12|
2024|01|02|03|04|

2014-01-11 :-)

_ 午前

1030 起床 && 部屋掃除

_ 午後

1200 おひる。うどん

1300 買い物

1500 コーヒーを飲むなど

1600 アニメ消化

_

1700 アニメ消化

2100 飯。かき鍋

2200 マルチスレッドがどうのこうの

_ [ruby][wait][notify][notify_all][マルチスレッド][スレッド]ruby で wait, notify_all とか

Java には wait, notify, notify_all があるんだが ruby にはない。C で云う signal と kill みたいなものぽい?(夕立)

ruby thread programming , ruby equivalent of java wait/notify/notifyAll - Stack Overflow

ふむ

多重に Mutex すると刺さるらしいので Monitor に変更してみたけどその辺よく分かってない( class Monitor )

# coding: utf-8

require 'thread'
require 'monitor'

class Object 
  def wait
    @waiting_threads = [] unless @waiting_threads
    @monitor_mutex = Monitor.new unless @monitor_mutex
    @monitor_mutex.synchronize {
      @waiting_threads << Thread.current
    }
    Thread.stop
  end

  def notify
    if @monitor_mutex and @waiting_threads 
      @monitor_mutex.synchronize {
        @waiting_threads.delete_at(0).run unless @waiting_threads.empty?
      }
    end
  end

  def notify_all
    if @monitor_mutex and @waiting_threads
      @monitor_mutex.synchronize {
        @waiting_threads.each {|thread| thread.run}
        @waiting_threads = []
      }
    end
  end
end


if __FILE__ == $0
  th1 = Thread.new do
    puts "thread1 wait..."
    wait()
    puts "thread1 wake up"
  end
  
  th2 = Thread.new do
    puts "thread2 signal..."
    3.downto(0) {|i|
      puts "...#{i}"
      sleep(1)
    }
    puts "fire!"
    notify_all()
  end
  
  th1.join
  th2.join
end
% ruby wait.rb
thread1 wait...
thread2 signal...
...3
...2
...1
...0
fire!
thread1 wake up

_ プログラマには集中しやすい仕事場を与えるべき

といっていたのはトム・デマルコだったかどうだったか。個室を与えろだとか、電話対応しなくていいとか、雑務は自分の仕事じゃない()とかそういうの。トム・デマルコに限らずいろんなひとが言ってたような気がする。要するに「コードを書くことに専念したいから他人と関わりたくない」ということだる。「集中できる環境が必要である!」俺にもそう思っていた時期がありました。学生のころ。

SIer ぽいひとがこのようなことを言ってるのをたまに見かけるんだけど、他人と関わらないで済む仕事とはどういうものがあるのか知りたい。SIer ぽいことやってるなら、プロジェクトを指揮ったり、営業と打ち合わせしたり、客先に出向いたり、資材を調達したり、検査部門に依頼をしたり、導入時に現場に寝泊まりなどするはずだから、個室で引きこもって仕事するなんてできないと思うんだけど。自宅から遠隔で仕事するひとであっても割り込みがあったり障害対応したりするよなあ。

華やかそうなオフィスであっても個室なんて見当たらないし。他人と関わらない仕事とはどういうひとたちなんだろうか。

4822281108

本日のツッコミ(全2件) [ツッコミを入れる]
_ エモエモ (2014-01-12 20:42)

関わるほうが楽しい派(´・ω・`)

_ みわ (2014-01-12 23:41)

こじらせると、見ざる言わざる聞かざるになってまう