[#12543] Ruby Conference 0.3 — greentea@...2.so-net.ne.jp (Tomoyuki Kosimizu)

こんにちは、こしみずです。

21 messages 1999/03/04
[#12570] Re: Ruby Conference 0.3 — matz@... (Yukihiro Matsumoto) 1999/03/05

まつもと ゆきひろです

[#12571] Re: Ruby Conference 0.3 — Takaaki Higuchi - Technology Marketing <Takaaki.Higuchi@...> 1999/03/05

> | >18日あたり東京でRuby Conference 0.3(単なる宴会)を開きましょうか?

[#12577] Re: Ruby Conference 0.3 — matz@... (Yukihiro Matsumoto) 1999/03/05

まつもと ゆきひろです

[#12645] Re: Ruby Conference 0.3 — KIMURA Koichi <kimura@...> 1999/03/08

[#12546] [閑話] Ruby Conference 0.3 参加したいぃ — Atsuko Yoshida <atsuko@...>

こんにちは。あつこです。

17 messages 1999/03/05
[#12548] Re: [ 閑話] Ruby Conference 0.3 参加したいぃ — KIMURA Koichi <kimura@...> 1999/03/05

[#12573] alternative name of iterator — Shugo Maeda <shugo@...>

前田です。

49 messages 1999/03/05
[#12584] Re: alternative name of iterator — matz@... (Yukihiro Matsumoto) 1999/03/05

まつもと ゆきひろです

[#12641] Re: alternative name of iterator — moochan <moochan@...> 1999/03/08

moochan です.

[#12642] Re: alternative name of iterator — matz@... (Yukihiro Matsumoto) 1999/03/08

まつもと ゆきひろです

[#12643] Re: alternative name of iterator — moochan <moochan@...> 1999/03/08

moochan です.

[#12644] Re: alternative name of iterator — matz@... (Yukihiro Matsumoto) 1999/03/08

まつもと ゆきひろです

[#12661] Re: alternative name of iterator — moochan <moochan@...> 1999/03/09

moochan です.

[#12662] Re: alternative name of iterator — matz@... (Yukihiro Matsumoto) 1999/03/09

まつもと ゆきひろです

[#12666] Re: alternative name of iterator — moochan <moochan@...> 1999/03/09

moochan です.

[#12590] kconv SJIS — Kikutani Makoto <kikutani@...>

=?ISO-2022-JP?B? ではじまるBエンコードされたサブジェクトは

20 messages 1999/03/06

[#12695] 第 2 回 OMG 分散コンピューティング・セミナー: CORBA3.0 の詳説と CORBA 活用の実際 — Junichi Suzuki <jun-sk@...>

各位.

19 messages 1999/03/10
[#12911] HORB for Ruby? — Shugo Maeda <shugo@...> 1999/03/16

前田です。

[#12707] Re: operater bind order ? — Inaba Hiroto <inaba@...>

稲葉です.

16 messages 1999/03/10
[#12709] Re: operater bind order ? — KIMURA Koichi <kimura@...> 1999/03/10

[#12727] Making of Interval class. — moochan <moochan@...>

moochan です.

40 messages 1999/03/10
[#12742] Re: Making of Interval class. — Shugo Maeda <shugo@...> 1999/03/11

前田です。

[#12746] Re: Making of Interval class. — moochan <moochan@...> 1999/03/11

moochan です.

[#12728] Time + 1M — Wakou Aoyama <wakou@...>

青山です。

30 messages 1999/03/10
[#12731] Re: Time + 1M — Tadayoshi Funaba <tadf@...> 1999/03/10

ふなばです。

[#12772] Re: Time + 1M — IKARASHI Akira <ikarashi@...> 1999/03/11

五十嵐です。

[#12774] Re: Time + 1M — Tadayoshi Funaba <tadf@...> 1999/03/11

ふなばです。

[#12775] Re: Time + 1M — IKARASHI Akira <ikarashi@...> 1999/03/11

五十嵐です。

[#12850] Ruby Conference 0.3 where ? when ? — ISII takesi <isii@...>

石井です。

89 messages 1999/03/15
[#12852] Re: Ruby Conference 0.3 where ? when ? — matz@... (Yukihiro Matsumoto) 1999/03/15

まつもと ゆきひろです

[#12859] Re: Ruby Conference 0.3 where ? when ? — hisanori@... 1999/03/15

松尾です。

[#12860] Re: Ruby Conference 0.3 where ? when ? — matz@... (Yukihiro Matsumoto) 1999/03/15

まつもと ゆきひろです

[#12861] Re: Ruby Conference 0.3 where ? when ? — hisanori@... 1999/03/15

松尾です。

[#12862] Re: Ruby Conference 0.3 where ? when ? — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/15

なひです.

[#12864] Re: Ruby Conference 0.3 where ? when ? — matz@... (Yukihiro Matsumoto) 1999/03/15

まつもと ゆきひろです

[#12870] Re: Ruby Conference 0.3 where ? when ? — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/15

なひです.

[#12872] Re: Ruby Conference 0.3 where ? when ? — matz@... (Yukihiro Matsumoto) 1999/03/15

まつもと ゆきひろです

[#12888] signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/15

なひです.

[#12896] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — matz@... (Yukihiro Matsumoto) 1999/03/16

まつもと ゆきひろです

[#12960] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/17

なひです.

[#12962] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — 中村暁史 <anakamur@...> 1999/03/17

[#12993] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/18

なひです.

[#12995] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — 中村暁史 <anakamur@...> 1999/03/18

[#13009] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/19

なひです.

[#13010] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/19

なひです.

[#13011] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — KIMURA Koichi <kimura@...> 1999/03/19

[#13013] Re: signal handler in Ruby( was Re: Ruby Conference 0.3 where ? when ? ) — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/19

なひです.

[#13016] Re: signal handler in Ruby( was Re: Ruby Conference 0.3 where ? when ? ) — 中村暁史 <anakamur@...> 1999/03/19

[#13023] Re: signal handler in Ruby( was Re: Ruby Conference 0.3 where ? when ? ) — "NAKAMURA, Hiroshi" <nakahiro@...> 1999/03/19

なひです.

[#13012] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — 中村暁史 <anakamur@...> 1999/03/19

[#13037] Re: signal handler in Ruby ( was Re: Ruby Conference 0.3 where ? when ? ) — keiju@... (石塚圭樹 ) 1999/03/20

けいじゅ@日本ラショナルソフトウェアです.

[#12918] Sieve of Eratosthenes (Re: [ruby-dev:6094]) — Shin-ichiro Hara <sinara@...>

原です。

29 messages 1999/03/16
[#12924] delete during each (Re: Sieve of Eratosthenes) — matz@... (Yukihiro Matsumoto) 1999/03/17

まつもと ゆきひろです

[#12930] Re: delete during each (Re: Sieve of Eratosthenes) — Shin-ichiro Hara <sinara@...> 1999/03/17

原です。

[#12932] Re: delete during each (Re: Sieve of Eratosthenes) — matz@... (Yukihiro Matsumoto) 1999/03/17

まつもと ゆきひろです

[#12934] Re: delete during each (Re: Sieve of Eratosthenes) — Shin-ichiro Hara <sinara@...> 1999/03/17

原です。

[#13091] FAQ for /:|) — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

17 messages 1999/03/23

[#13121] 全角文字列の分割方法について — goto@...

初めまして、後藤@横河工事(橋梁技術者)です。

17 messages 1999/03/24
[#13122] Re: 全角文字列の分割方法について — matz@... (Yukihiro Matsumoto) 1999/03/24

まつもと ゆきひろです

[#13123] Re: 全角文字列の分割方法について — goto@... 1999/03/24

後藤@横河工事(橋梁技術者)です。お世話になります。

[#13134] ロックでアドバイスをいただきたいのですが — Keisuke Minami <keisuke@...>

はじめまして。三並と申します。

30 messages 1999/03/24
[#13136] Re: ロックでアドバイスをいただきたいのですが — hisanori@... 1999/03/24

松尾です。

[#13139] Re: ロックでアドバイスをいただきたいのですが — 中村暁史 <anakamur@...> 1999/03/24

[#13188] CGI (Re: ロックでアドバイスをいただきたいのですが) — Shugo Maeda <shugo@...> 1999/03/25

前田です。

[#13190] Re: CGI (Re: ロックでアドバイスをいただきたいのですが) — hisanori@... 1999/03/25

松尾です。

[#13140] Ruby Conference 0.3 — hisanori@...

松尾です。

25 messages 1999/03/24

[ruby-list:12955] Re: mutex_m.rb & sync.rb for 1.3

From: Shugo Maeda <shugo@...>
Date: 1999-03-17 09:01:09 UTC
List: ruby-list #12955
前田です。

matz@netlab.co.jp (Yukihiro Matsumoto) writes:

> |mutex_m.rbとsync.rbを1.3系に対応させてみました。
> 
> sync.rbが壊れてるみたい.うちの問題なのかなあ.

すいません、原因はわかりませんが圧縮せずに再送します。
# X-Dispatcherが怪しいような。


-- 
前田 修吾

Attachments (1)

sync.rb (6.19 KB, text/x-ruby)
#
#   sync.rb - 2 phase lock with counter
#   	$Release Version: 0.2$
#   	$Revision: 1.1.1.3.2.1 $
#   	$Date: 1999/02/09 06:08:24 $
#   	by Keiju ISHITSUKA
#   	modified by matz
#
# --
#  Sync_m, Synchronizer_m
#  Usage:
#   obj.extend(Sync_m)
#   or
#   class Foo
#	Sync_m.include_to self
#	:
#   end
#
#   Sync_m#sync_mode
#   Sync_m#sync_locked?, locked?
#   Sync_m#sync_shared?, shared?
#   Sync_m#sync_exclusive?, sync_exclusive?
#   Sync_m#sync_try_lock, try_lock
#   Sync_m#sync_lock, lock
#   Sync_m#sync_unlock, unlock
#
#   Sync, Synchronicer:
#	include Sync_m
#   Usage:
#   sync = Sync.new
#
#   Sync#mode
#   Sync#locked?
#   Sync#shared?
#   Sync#exclusive?
#   Sync#try_lock(mode) -- mode = :EX, :SH, :UN
#   Sync#lock(mode)     -- mode = :EX, :SH, :UN
#   Sync#unlock
#   Sync#synchronize(mode) {...}
#   
#

unless defined? Thread
  fail "Thread not available for this ruby interpreter"
end

module Sync_m
  RCS_ID='-$Header: /home/cvsroot/ruby/lib/sync.rb,v 1.1.1.3.2.1 1999/02/09 06:08:24 matz Exp $-'
  
  # lock mode
  UN = :UN
  SH = :SH
  EX = :EX
  
  # exceptions
  class Err < StandardError
    def Err.Fail(*opt)
      fail self, sprintf(self::Message, *opt)
    end
    
    class UnknownLocker < Err
      Message = "Thread(%s) not locked."
      def UnknownLocker.Fail(th)
	super(th.inspect)
      end
    end
    
    class LockModeFailer < Err
      Message = "Unknown lock mode(%s)"
      def LockModeFailer.Fail(mode)
	if mode.id2name
	  mode = id2name
	end
	super(mode)
      end
    end
  end
  
  def Sync_m.append_features(cl)
    super
    unless cl.instance_of?(Module)
      # do nothing for Modules
      # make aliases and include the proper module.
      cl.module_eval %q{
	alias locked? sync_locked?
	alias shared? sync_shared?
	alias exclusive? sync_exclusive?
	alias lock sync_lock
	alias unlock sync_unlock
	alias try_lock sync_try_lock
	alias synchronize sync_synchronize
      }
    end
    return self
  end
  
  def Sync_m.extend_object(obj)
    super
    obj.sync_extended
  end
  
  def sync_extended
    unless (defined? locked? and
	    defined? shared? and
	    defined? exclusive? and
	    defined? lock and
	    defined? unlock and
	    defined? try_lock and
	    defined? synchronize)
      eval "class << self
	alias locked? sync_locked?
        alias shared? sync_shared?
        alias exclusive? sync_exclusive?
	alias lock sync_lock
	alias unlock sync_unlock
	alias try_lock sync_try_lock
	alias synchronize sync_synchronize
      end"
    end
    initialize
  end
  
  # accessing
  def sync_locked?
    sync_mode != UN
  end
  
  def sync_shared?
    sync_mode == SH
  end
  
  def sync_exclusive?
    sync_mode == EX
  end
  
  # locking methods.
  def sync_try_lock(mode = EX)
    return unlock if sync_mode == UN
    
    Thread.critical = true
    ret = sync_try_lock_sub(sync_mode)
    Thread.critical = false
    ret
  end
  
  def sync_lock(m = EX)
    return unlock if m == UN

    until (Thread.critical = true; sync_try_lock_sub(m))
      if sync_sh_locker[Thread.current]
	sync_upgrade_waiting.push [Thread.current, sync_sh_locker[Thread.current]]
	sync_sh_locker.delete(Thread.current)
      else
	sync_waiting.push Thread.current
      end
      Thread.stop
    end
    Thread.critical = false
    self
  end
  
  def sync_unlock(m = EX)
    Thread.critical = true
    if sync_mode == UN
      Thread.critical = false
      Err::UnknownLocker.Fail(Thread.current)
    end
    
    m = sync_mode if m == EX and sync_mode == SH
    
    runnable = false
    case m
    when UN
      Thread.critical = false
      Err::UnknownLocker.Fail(Thread.current)
      
    when EX
      if sync_ex_locker == Thread.current
	if (self.sync_ex_count = sync_ex_count - 1) == 0
	  self.sync_ex_locker = nil
	  if sync_sh_locker.include?(Thread.current)
	    self.sync_mode = SH
	  else
	    self.sync_mode = UN
	  end
	  runnable = true
	end
      else
	Err::UnknownLocker.Fail(Thread.current)
      end
      
    when SH
      if (count = sync_sh_locker[Thread.current]).nil?
	Err::UnknownLocker.Fail(Thread.current)
      else
	if (sync_sh_locker[Thread.current] = count - 1) == 0 
	  sync_sh_locker.delete(Thread.current)
	  if sync_sh_locker.empty? and sync_ex_count == 0
	    self.sync_mode = UN
	    runnable = true
	  end
	end
      end
    end
    
    if runnable
      if sync_upgrade_waiting.size > 0
	for k, v in sync_upgrade_waiting
	  sync_sh_locker[k] = v
	end
	wait = sync_upgrade_waiting
	self.sync_upgrade_waiting = []
	Thread.critical = false
	
	for w, v in wait
	  w.run
	end
      else
	wait = sync_waiting
	self.sync_waiting = []
	Thread.critical = false
	for w in wait
	  w.run
	end
      end
    end
    
    Thread.critical = false
    self
  end
  
  def sync_synchronize(mode = EX)
    sync_lock(mode)
    begin
      yield
    ensure
      sync_unlock
    end
  end
  
  attr :sync_mode, true
  attr :sync_waiting, true
  attr :sync_upgrade_waiting, true
  attr :sync_sh_locker, true
  attr :sync_ex_locker, true
  attr :sync_ex_count, true

  private

  def initialize(*args)
    ret = super
    @sync_mode = UN
    @sync_waiting = []
    @sync_upgrade_waiting = []
    @sync_sh_locker = Hash.new
    @sync_ex_locker = nil
    @sync_ex_count = 0
    return ret
  end
  
  def sync_try_lock_sub(m)
    case m
    when SH
      case sync_mode
      when UN
	self.sync_mode = m
	sync_sh_locker[Thread.current] = 1
	ret = true
      when SH
	count = 0 unless count = sync_sh_locker[Thread.current]
	sync_sh_locker[Thread.current] = count + 1
	ret = true
      when EX
	# in EX mode, lock will upgrade to EX lock
	if sync_ex_locker == Thread.current
	  self.sync_ex_count = sync_ex_count + 1
	  ret = true
	else
	  ret = false
	end
      end
    when EX
      if sync_mode == UN or
	sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current) 
	self.sync_mode = m
	self.sync_ex_locker = Thread.current
	self.sync_ex_count = 1
	ret = true
      elsif sync_mode == EX && sync_ex_locker == Thread.current
	self.sync_ex_count = sync_ex_count + 1
	ret = true
      else
	ret = false
      end
    else
      Thread.critical = false
      Err::LockModeFailer.Fail mode
    end
    return ret
  end
end
Synchronizer_m = Sync_m

class Sync
  include Sync_m
  
  private
    
  def initialize
    super
  end
end
Synchronizer = Sync

In This Thread

Prev Next