roby 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,13 @@
1
+ === 0.7.2
2
+
3
+ * fixed a memory leak regarding the event propagation histories. Until now,
4
+ all the propagation histories where kept through Event#sources, leading to
5
+ actually keeping most plan objects since the beginning of execution. This
6
+ is fixed by internally using weak references. Histories will therefore be
7
+ truncated as the Ruby GC removes references to the concerned plan objects.
8
+ * misc small fixes, which mostly remove some false negatives in the test suite
9
+ * small change to be compatible with 1.8.7
10
+
1
11
  === 0.7.1
2
12
 
3
13
  * Fixed extension handling in 'rake setup'. It should work again.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ begin
15
15
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
16
16
  p.post_install_message = p.paragraphs_of('README.txt', 2).join("\n\n")
17
17
 
18
- p.extra_deps << ['facets', '>= 2.0'] << 'activesupport' << ['utilrb', '1.2']
18
+ p.extra_deps << ['facets', '>= 2.0'] << 'activesupport' << ['utilrb', '>= 1.3.1']
19
19
  if p.respond_to? :need_rdoc=
20
20
  p.need_rdoc = false
21
21
  end
@@ -39,3 +39,4 @@ require 'roby/interface'
39
39
  require 'roby/distributed/protocol'
40
40
 
41
41
  require 'roby/app'
42
+
@@ -1,5 +1,14 @@
1
+ if RUBY_VERSION >= "1.9"
2
+ STDERR.puts <<-EOB
3
+ The stable version of Roby is not compatible with 1.9. If you really want to
4
+ try it on 1.9, checkout the 1.9 branch of the development repository on github
5
+ (see README.txt for URLs)
6
+ EOB
7
+ exit(1)
8
+ end
9
+
1
10
  module Roby
2
- VERSION = '0.7.1'
11
+ VERSION = '0.7.2'
3
12
  ROBY_LIB_DIR = File.expand_path( File.join(File.dirname(__FILE__), '..') )
4
13
  ROBY_ROOT_DIR = File.expand_path( File.join(ROBY_LIB_DIR, '..') )
5
14
  end
@@ -492,7 +492,6 @@ module Roby
492
492
  cv.wait(mt)
493
493
  end
494
494
  end
495
- raise unless @thread
496
495
  return
497
496
  end
498
497
 
@@ -265,7 +265,10 @@ module Roby
265
265
  while !pending_sockets.empty?
266
266
  socket, peer = pending_sockets.shift
267
267
  sockets[socket] = peer
268
- Roby::Distributed.info "listening to #{socket.peer_info} for #{peer}"
268
+ begin
269
+ Roby::Distributed.info "listening to #{socket.peer_info} for #{peer}"
270
+ rescue IOError
271
+ end
269
272
  end
270
273
 
271
274
  begin
@@ -282,18 +285,22 @@ module Roby
282
285
  next
283
286
  end
284
287
 
285
- header = socket.read(8)
286
- unless header && header.size == 8
287
- closed_sockets << socket
288
- next
289
- end
290
-
291
- id, size = header.unpack("NN")
292
- data = socket.read(size)
293
-
294
- p = sockets[socket]
295
- p.stats.rx += (size + 8)
296
- Roby::Distributed.cycles_rx << [p, Marshal.load(data)]
288
+ begin
289
+ header = socket.read(8)
290
+ unless header && header.size == 8
291
+ closed_sockets << socket
292
+ next
293
+ end
294
+
295
+ id, size = header.unpack("NN")
296
+ data = socket.read(size)
297
+
298
+ p = sockets[socket]
299
+ p.stats.rx += (size + 8)
300
+ Roby::Distributed.cycles_rx << [p, Marshal.load(data)]
301
+ rescue Errno::ECONNRESET, IOError
302
+ closed_sockets << socket
303
+ end
297
304
  end
298
305
 
299
306
  for socket in closed_sockets
@@ -1,3 +1,4 @@
1
+ require 'utilrb/weakref'
1
2
  require 'roby/plan-object'
2
3
  require 'roby/exceptions'
3
4
  require 'set'
@@ -11,14 +12,42 @@ module Roby
11
12
  # The generator which emitted this event
12
13
  attr_reader :generator
13
14
 
15
+ @@creation_places = Hash.new
14
16
  def initialize(generator, propagation_id, context, time = Time.now)
15
17
  @generator, @propagation_id, @context, @time = generator, propagation_id, context.freeze, time
18
+
19
+ @@creation_places[object_id] = "#{generator.class}"
16
20
  end
17
21
 
18
22
  attr_accessor :propagation_id, :context, :time
19
- attr_accessor :sources
20
23
  protected :propagation_id=, :context=, :time=
21
24
 
25
+ # The events whose emission triggered this event during the
26
+ # propagation. The events in this set are subject to Ruby's own
27
+ # garbage collection, which means that if a source event is garbage
28
+ # collected (i.e. if all references to the associated task/event
29
+ # generator are removed), it will be removed from this set as well.
30
+ def sources
31
+ result = []
32
+ @sources.delete_if do |ref|
33
+ begin
34
+ result << ref.get
35
+ false
36
+ rescue Utilrb::WeakRef::RefError
37
+ true
38
+ end
39
+ end
40
+ result
41
+ end
42
+
43
+ # Sets the sources. See #sources
44
+ def sources=(sources) # :nodoc:
45
+ @sources = ValueSet.new
46
+ for s in sources
47
+ @sources << Utilrb::WeakRef.new(s)
48
+ end
49
+ end
50
+
22
51
  # To be used in the event generators ::new methods, when we need to reemit
23
52
  # an event while changing its
24
53
  def reemit(new_id, new_context = nil)
@@ -35,7 +64,9 @@ module Roby
35
64
 
36
65
  def name; model.name end
37
66
  def model; self.class end
38
- def inspect; "#<#{model.to_s}:0x#{address.to_s(16)} generator=#{generator} model=#{model}" end
67
+ def inspect # :nodoc:
68
+ "#<#{model.to_s}:0x#{address.to_s(16)} generator=#{generator} model=#{model}"
69
+ end
39
70
 
40
71
  # Returns an event generator which will be emitted once +time+ seconds
41
72
  # after this event has been emitted.
@@ -43,10 +74,11 @@ module Roby
43
74
  State.at :t => (self.time + time)
44
75
  end
45
76
 
46
- def to_s
77
+ def to_s # :nodoc:
47
78
  "[#{time.to_hms} @#{propagation_id}] #{self.class.to_s}: #{context}"
48
79
  end
49
- def pretty_print(pp)
80
+
81
+ def pretty_print(pp) # :nodoc:
50
82
  pp.text "[#{time.to_hms} @#{propagation_id}] #{self.class}"
51
83
  if context
52
84
  pp.breakable
@@ -691,6 +723,8 @@ module Roby
691
723
  return if @unreachable
692
724
  @unreachable = true
693
725
 
726
+ EventGenerator.event_gathering.delete(self)
727
+
694
728
  unreachable_handlers.each do |_, block|
695
729
  begin
696
730
  block.call(reason)
@@ -217,9 +217,23 @@ module Roby
217
217
  # Returns true if this object has no member
218
218
  def empty?; @members.empty? end
219
219
 
220
- def respond_to?(name) # :nodoc:
221
- return true if super
220
+ if RUBY_VERSION >= "1.8.7"
221
+ def respond_to?(name, include_private = false) # :nodoc:
222
+ return true if super
223
+ return __respond_to__(name)
224
+ end
225
+ else
226
+ def respond_to?(name) # :nodoc:
227
+ return true if super
228
+ return __respond_to__(name)
229
+ end
230
+ end
231
+
222
232
 
233
+ # 1.8.7's #respond_to? takes two arguments, 1.8.6 only one. This is the
234
+ # common implementation for both version. #respond_to? is adapted (see
235
+ # above)
236
+ def __respond_to__(name) # :nodoc:
223
237
  name = name.to_s
224
238
  return false if name =~ FORBIDDEN_NAMES_RX
225
239
 
@@ -56,14 +56,13 @@ module Roby
56
56
  # event
57
57
  def task_sources
58
58
  result = ValueSet.new
59
- if sources
60
- for ev in sources
61
- gen = ev.generator
62
- if gen.respond_to?(:task) && gen.task == task
63
- result.merge ev.task_sources
64
- end
65
- end
66
- end
59
+ event_sources = sources
60
+ for ev in event_sources
61
+ gen = ev.generator
62
+ if gen.respond_to?(:task) && gen.task == task
63
+ result.merge ev.task_sources
64
+ end
65
+ end
67
66
  if result.empty?
68
67
  result << self
69
68
  end
@@ -764,6 +764,7 @@ class TC_Event < Test::Unit::TestCase
764
764
  # removed from the plan
765
765
  collection.clear
766
766
  plan.remove_object(e1)
767
+ assert(!EventGenerator.event_gathering.has_key?(e1))
767
768
 
768
769
  EventGenerator.remove_event_gathering(collection)
769
770
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-29 00:00:00 +02:00
12
+ date: 2008-06-14 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -35,9 +35,9 @@ dependencies:
35
35
  version_requirement:
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "="
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: "1.2"
40
+ version: 1.3.1
41
41
  version:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: hoe