tsafe 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -1,9 +1,9 @@
1
1
  #Predefined synchronized array.
2
2
  #
3
3
  #===Examples
4
- # arr = Tsafe::MonArray.new
5
- # arr << 5
6
- # ret = arr[0]
4
+ # arr = Tsafe::MonArray.new
5
+ # arr << 5
6
+ # ret = arr[0]
7
7
  class Tsafe::MonArray < ::Array
8
8
  @@tsafe_rwmutex_w_methods = [:<<, :collect, :collect!, :compact!, :delete, :delete_at, :delete_if, :drop, :drop_while, :fill, :flatten!, :insert, :keep_if, :map, :map!, :replace, :shuffle!, :slice!, :shift, :sort!, :sort_by!, :unshift]
9
9
  @@tsafe_rwmutex_r_methods = [:each, :each_index, :take_while]
@@ -1,9 +1,9 @@
1
1
  #Predefined synchronized hash.
2
2
  #
3
3
  #===Examples
4
- # h = Tsafe::MonHash.new
5
- # h['test'] = 'trala'
6
- # ret = h['test']
4
+ # h = Tsafe::MonHash.new
5
+ # h['test'] = 'trala'
6
+ # ret = h['test']
7
7
  class Tsafe::MonHash < ::Hash
8
8
  @@tsafe_mrswlock_w_methods = [:[]=, :clear, :delete, :delete_if, :keep_if, :merge!, :rehash, :reject!, :replace, :select!, :shift, :store, :update, :values_at]
9
9
  @@tsafe_mrswlock_r_methods = [:each, :each_key, :each_pair, :each_value]
@@ -1,9 +1,9 @@
1
1
  #This module can be included on a class to make all method-calls synchronized (by using monitor). Examples with array and hash are below.
2
2
  #
3
3
  #===Examples
4
- # class MySyncedClass < SomeOtherClassThatNeedsToBeSynchronized
5
- # include Tsafe::Monitored
6
- # end
4
+ # class MySyncedClass < SomeOtherClassThatNeedsToBeSynchronized
5
+ # include Tsafe::Monitored
6
+ # end
7
7
  module Tsafe::Monitored
8
8
  def self.included(base)
9
9
  base.to_s.split("::").inject(Object, :const_get).class_eval do
@@ -34,8 +34,8 @@ class Tsafe::Mrswlock
34
34
  end
35
35
  end
36
36
 
37
- # Runs the given block through the write-synchronization (locks both reading and writing).
38
- # ===Examples
37
+ #Runs the given block through the write-synchronization (locks both reading and writing).
38
+ #===Examples
39
39
  # lock.wsync do
40
40
  # #do something within lock.
41
41
  # end
@@ -65,11 +65,11 @@ class Tsafe::Mrswlock
65
65
 
66
66
  #This module can be included in order to painlessly make a thread-safe multi-reader-single-writer thread-safe copy of a class.
67
67
  #===Examples
68
- # class Tsafe::MonHash < ::Hash
69
- # @@tsafe_mrswlock_w_methods = [:[]=, :clear, :delete, :delete_if, :keep_if, :merge!, :rehash, :reject!, :replace, :select!, :shift, :store, :update, :values_at]
70
- # @@tsafe_mrswlock_r_methods = [:each, :each_key, :each_pair, :each_value]
71
- # include Tsafe::Mrswlock::SynModule
72
- # end
68
+ # class Tsafe::MonHash < ::Hash
69
+ # @@tsafe_mrswlock_w_methods = [:[]=, :clear, :delete, :delete_if, :keep_if, :merge!, :rehash, :reject!, :replace, :select!, :shift, :store, :update, :values_at]
70
+ # @@tsafe_mrswlock_r_methods = [:each, :each_key, :each_pair, :each_value]
71
+ # include Tsafe::Mrswlock::SynModule
72
+ # end
73
73
  module SynModule
74
74
  def self.included(base)
75
75
  base.to_s.split("::").inject(Object, :const_get).class_eval do
@@ -1,9 +1,9 @@
1
1
  #This module can be included on a class to make all method-calls synchronized (by using mutex). Examples with array and hash are below.
2
2
  #
3
3
  #===Examples
4
- # class MySyncedClass < SomeOtherClassThatNeedsToBeSynchronized
5
- # include Tsafe::Mutexed
6
- # end
4
+ # class MySyncedClass < SomeOtherClassThatNeedsToBeSynchronized
5
+ # include Tsafe::Mutexed
6
+ # end
7
7
  module Tsafe::Mutexed
8
8
  def self.included(base)
9
9
  base.to_s.split("::").inject(Object, :const_get).class_eval do
@@ -1,13 +1,13 @@
1
1
  #Instances of this class proxies calls to a given-object by using a mutex or monitor.
2
2
  #
3
3
  #==== Examples
4
- # threadsafe_array = Tsafe::Proxy.new(:obj => [])
5
- # threadsafe_array << 5
6
- # ret = threadsafe_array[0]
7
- #
8
- # threadsafe_array = Tsafe::Proxy.new(:obj => [], :monitor => true)
4
+ # threadsafe_array = Tsafe::Proxy.new(:obj => [])
5
+ # threadsafe_array << 5
6
+ # ret = threadsafe_array[0]
7
+ #
8
+ # threadsafe_array = Tsafe::Proxy.new(:obj => [], :monitor => true)
9
9
  class Tsafe::Proxy
10
- #Spawn needed vars.
10
+ #Spawns needed vars.
11
11
  def initialize(args)
12
12
  if args[:monitor]
13
13
  @mutex = Monitor.new
@@ -14,14 +14,20 @@ describe "Tsafe::Rwmutex" do
14
14
  hash[realcount] = realcount
15
15
  end
16
16
 
17
+ called = false
17
18
  hash._tsafe_rsync do
18
-
19
+ called = true
19
20
  end
20
21
 
22
+ raise "Expected to be called." if !called
23
+
24
+ called = false
21
25
  hash._tsafe_wsync do
22
-
26
+ called = true
23
27
  end
24
28
 
29
+ raise "Expected to be called." if !called
30
+
25
31
  ts = []
26
32
 
27
33
  1.upto(10) do |tcount|
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tsafe}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tsafe
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- hash: -2179111406446538403
103
+ hash: 1466962052017061704
104
104
  segments:
105
105
  - 0
106
106
  version: "0"