Forked from tarcieri/concurrent_nested_hash.rb
Last active
December 16, 2015 08:29
Revisions
-
//de revised this gist
Apr 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,6 @@ def has_key?( key ); @outer.has_key? key end def merge( h ); @outer.merge h end def merge!( h ); @outer.merge! h end def delete( key ); @outer.delete key end def sort_by( &block ); @outer.sort_by &block end def count; @outer.count end end -
//de revised this gist
Apr 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,6 @@ def has_key?( key ); @outer.has_key? key end def merge( h ); @outer.merge h end def merge!( h ); @outer.merge! h end def delete( key ); @outer.delete key end #de def sort_by( *args ); @outer.sort_by yield( args ) end FAIL def count; @outer.count end end -
//de revised this gist
Apr 18, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,5 +19,6 @@ def has_key?( key ); @outer.has_key? key end def merge( h ); @outer.merge h end def merge!( h ); @outer.merge! h end def delete( key ); @outer.delete key end #de def sort_by( *args ); @outer.sort_by yield( args ) end def count; @outer.count end end -
//de revised this gist
Apr 17, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,4 +19,5 @@ def has_key?( key ); @outer.has_key? key end def merge( h ); @outer.merge h end def merge!( h ); @outer.merge! h end def delete( key ); @outer.delete key end def count; @outer.count end end -
//de revised this gist
Apr 17, 2013 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,21 +2,21 @@ class ConcurrentNestedHash include Celluloid def initialize( starting = {} ); @outer = starting end def [](*keys); keys.inject(@outer) { |h,k| h[k] } end def []=(*args) value = args.pop raise ArgumentError, "wrong number of arguments (1 for 2)" if args.empty? key = args.pop hash = args.inject(@outer) { |h,k| h[k] ||= {} } hash[key] = value end def has_key?( key ); @outer.has_key? key end def merge( h ); @outer.merge h end def merge!( h ); @outer.merge! h end def delete( key ); @outer.delete key end end -
tarcieri revised this gist
Mar 12, 2012 . 1 changed file with 9 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,22 @@ require 'celluloid' class ConcurrentNestedHash include Celluloid def initialize @outer = {} end def [](*keys) keys.inject(@outer) { |h,k| h[k] } end def []=(*args) value = args.pop raise ArgumentError, "wrong number of arguments (1 for 2)" if args.empty? key = args.pop hash = args.inject(@outer) { |h,k| h[k] ||= {} } hash[key] = value end end -
tarcieri revised this gist
Mar 12, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,5 +22,4 @@ def []=(*args) end def inspect; @mutex.synchronize { super }; end end -
tarcieri revised this gist
Mar 12, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,7 @@ def []=(*args) hash[key] = value end end def inspect; @mutex.synchronize { super }; end def to_s; @mutex.synchronize { super }; end end -
tarcieri revised this gist
Mar 12, 2012 . 2 changed files with 23 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ require 'thread' class ConcurrentNestedHash def initialize @outer = {} @mutex = Mutex.new end def [](*keys) @mutex.synchronize { keys.inject(@outer) { |h,k| h[k] } } end def []=(*args) @mutex.synchronize do value = args.pop raise ArgumentError, "wrong number of arguments (1 for 2)" if args.empty? key = args.pop hash = args.inject(@outer) { |h,k| h[k] ||= {} } hash[key] = value end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +0,0 @@ -
tarcieri created this gist
Mar 12, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ class NestedHash def initialize @outer = {} end def [](*keys) keys.inject(@outer) { |h,k| h[k] } end def []=(*args) value = args.pop raise ArgumentError, "wrong number of arguments (1 for 2)" if args.empty? key = args.pop hash = args.inject(@outer) { |h,k| h[k] ||= {} } hash[key] = value end end