File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 11require 'cgi'
22require 'yaml'
3+ require 'monitor'
34
45module Debugger
56
@@ -31,6 +32,20 @@ def cleanup_backtrace(backtrace)
3132 end
3233 end
3334
35+ def self . protect ( mname )
36+ return if instance_methods . include? ( "__#{ mname } " )
37+ alias_method "__#{ mname } " , mname
38+ class_eval %{
39+ def #{ mname } (*args, &block)
40+ @@monitor.synchronize do
41+ return unless @interface
42+ __#{ mname } (*args, &block)
43+ end
44+ end
45+ }
46+ end
47+
48+ @@monitor = Monitor . new
3449 attr_accessor :interface
3550
3651 def initialize ( interface )
@@ -293,6 +308,12 @@ def print(*params)
293308 Debugger ::print_debug ( *params )
294309 @interface . print ( *params )
295310 end
311+
312+ instance_methods . each do |m |
313+ if m . index ( 'print_' ) == 0
314+ protect m
315+ end
316+ end
296317
297318 end
298319
You can’t perform that action at this time.
0 commit comments