Skip to content

Commit 175f2ef

Browse files
committed
added synchronization between command processors threads
1 parent 12fc83c commit 175f2ef

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/ruby-debug/xml_printer.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'cgi'
22
require 'yaml'
3+
require 'monitor'
34

45
module 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

0 commit comments

Comments
 (0)