lib/php_process.rb in php_process-0.0.6 vs lib/php_process.rb in php_process-0.0.7
- old
+ new
@@ -1,9 +1,9 @@
-require "knjrbfw"
-require "knj/wref"
-require "base64"
+require "wref"
+require "tsafe"
require "php-serialize4ruby"
+require "base64"
require "open3"
#This class starts a PHP-process and proxies various calls to it. It also spawns proxy-objects, which can you can call like they were normal Ruby-objects.
#===Examples
# php = Php_process.new
@@ -30,15 +30,19 @@
# php = Php_process.new(:debug => true)
def initialize(args = {})
@args = args
@debug = @args[:debug]
@send_count = 0
- @responses = Knj::Threadsafe::Synced_hash.new
- @object_ids = Knj::Threadsafe::Synced_hash.new
- @object_unset_ids = Knj::Threadsafe::Synced_array.new
- @objects = Knj::Wref_map.new
+ @responses = Tsafe::MonHash.new
+
+ @object_ids = Tsafe::MonHash.new
+ @object_unset_ids = Tsafe::MonArray.new
+ @objects = Wref_map.new
+
+ @constant_val_cache = Tsafe::MonHash.new
+
#Used for 'create_func'.
@callbacks = {}
@callbacks_count = 0
@callbacks_mutex = Mutex.new
@@ -232,10 +236,16 @@
end
end
#Returns the value of a constant on the PHP-side.
def constant_val(name)
- return self.send(:type => :constant_val, :name => name)
+ const_name = name.to_s
+
+ if !@constant_val_cache.key?(const_name)
+ @constant_val_cache[const_name] = self.send(:type => :constant_val, :name => name)
+ end
+
+ return @constant_val_cache[const_name]
end
#Returns various informations about boths sides memory in a hash.
def memory_info
return {
\ No newline at end of file