dango 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -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
|
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.
|
24
|
-
hash[
|
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
|
-
|
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
|
-
|
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
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.
|
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-
|
12
|
+
date: 2008-09-03 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|