dango 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ class DangoClientFramework
16
16
 
17
17
  # send_action_return_notice用の共有メモリ
18
18
  def send_return_shared_init
19
- @send_return_shared = SharedMemoryStore.new
19
+ @send_return_shared = SharedMemoryStore.new({})
20
20
  end
21
21
  def send_return_shared
22
22
  @send_return_shared
@@ -45,6 +45,7 @@ class DangoServerFramework
45
45
 
46
46
  ServerStopWait = 0.2 # サーバー停止時のGServerの確認待ち時間
47
47
 
48
+ MainLoopWaitSec = 3.0 # メインループの待ち時間(サーバー内ファイルのチェック時間)
48
49
 
49
50
  class DangoGServer < GServer
50
51
  def initialize(parent, *args)
@@ -146,7 +147,7 @@ class DangoServerFramework
146
147
  server_start()
147
148
 
148
149
  loop do # 待ちで無限ループに入る
149
- sleep 3
150
+ sleep MainLoopWaitSec
150
151
  # p( Time.now_to_s + ":#{@server_reload.inspect}")
151
152
  check_reload_class()
152
153
  end
@@ -574,9 +575,9 @@ EOF
574
575
  # コンフィグのshared_database_managerによる使用クラスの選択
575
576
  def select_shared_database_manager()
576
577
  if @config['server']['shared_database_manager'] == 'MemoryStore'
577
- SharedMemoryStore.new
578
+ SharedMemoryStore.new(@config)
578
579
  else
579
- SharedMemoryStore.new
580
+ SharedMemoryStore.new(@config)
580
581
  end
581
582
  end
582
583
 
@@ -8,7 +8,8 @@
8
8
  module DangoFrameworkModule
9
9
  # 共有メモリ
10
10
  class SharedMemoryStore
11
- def initialize
11
+ def initialize(config)
12
+ @config = config
12
13
  @data = {}
13
14
  @mutex = {}
14
15
  @size = 0
@@ -20,13 +21,14 @@ module DangoFrameworkModule
20
21
 
21
22
  def to_hash
22
23
  hash = {}
23
- @data.keys.each do |key|
24
- hash[key] = @data[key].deep_dup
24
+ @data.each do |k, v|
25
+ hash[k.to_s] = v.deep_dup
25
26
  end
26
27
  hash
27
28
  end
28
29
 
29
30
  def transaction(key) # トランザクション処理ブロックを作る
31
+ key = key.to_s
30
32
  if !@mutex.has_key?(key) # 未定義キーならエラー
31
33
  raise(DangoFrameworkException, "Shared key is not exist.")
32
34
  end
@@ -37,34 +39,19 @@ module DangoFrameworkModule
37
39
  end
38
40
  end
39
41
 
40
- def synchronize(key) # 排他処理ブロック用
41
- if !@mutex.has_key?(key) # 未定義キーならエラー
42
- raise(DangoFrameworkException, "Shared key is not exist.")
43
- end
44
- @mutex[key].synchronize do
45
- yield
46
- end
47
- end
48
-
49
42
  def has_key?(key) # キーがあるかどうかを返す
50
- @mutex.has_key?(key)
43
+ key = key.to_s
44
+ @data.has_key?(key)
51
45
  end
52
46
 
53
47
  def [](key)
48
+ key = key.to_s
54
49
  if !@mutex.has_key?(key) # 未定義キーならエラー
55
50
  return(nil)
56
51
  # raise(DangoFrameworkException, "Shared key is not exist.")
57
52
  end
58
53
 
59
- # ロックしてデータを読む
60
- if @mutex[key].locked?
61
- data = @data[key].deep_dup
62
- else
63
- data = @mutex[key].synchronize do
64
- @data[key].deep_dup
65
- end
66
- end
67
- data
54
+ @data[key].deep_dup
68
55
  end
69
56
 
70
57
  def []=(key, value)
@@ -73,19 +60,19 @@ module DangoFrameworkModule
73
60
  raise(DangoFrameworkException, "Shared key is not String or Symbol.")
74
61
  end
75
62
 
63
+ key = key.to_s
64
+
76
65
  # 未定義なら定義する
77
66
  if !@mutex.has_key?(key)
78
67
  @mutex[key] = Mutex.new
79
68
  end
80
69
 
81
70
  # ロックしてデータを入れる
82
- if @mutex[key].locked?
71
+ @mutex[key].synchronize do
83
72
  @data[key] = value.deep_dup
84
- else
85
- @mutex[key].synchronize do
86
- @data[key] = value.deep_dup
87
- end
88
73
  end
74
+
75
+ nil
89
76
  end
90
77
  end
91
78
 
@@ -187,7 +187,7 @@ class TestClient < DangoClientFramework
187
187
 
188
188
  # dango_client_send_receive_data用の共有メモリ
189
189
  def send_receive_shared_init
190
- @send_receive_shared = SharedMemoryStore.new
190
+ @send_receive_shared = SharedMemoryStore.new({})
191
191
  end
192
192
  attr_reader(:send_receive_shared)
193
193
 
data/lib/dango/version.rb CHANGED
@@ -2,7 +2,7 @@ module Dango #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 8
5
+ TINY = 9
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dango
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keisuke Minami
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-05 00:00:00 +09:00
12
+ date: 2008-09-03 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency