• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-concurrency / concurrent-ruby / #2701

12 Feb 2015 06:34PM UTC coverage: 92.31% (+0.6%) from 91.69%
#2701

push

lucasallan
Merge pull request #238 from ruby-concurrency/semaphore-pure-java

Implementation of Concurrent::JavaSemaphore in pure Java.

2881 of 3121 relevant lines covered (92.31%)

390.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.61
/lib/concurrent/actor/behaviour/linking.rb
1
module Concurrent
1✔
2
  module Actor
1✔
3
    module Behaviour
1✔
4

5
      # Links the actor to other actors and sends actor's events to them,
6
      # like: `:terminated`, `:paused`, errors, etc
7
      # TODO example
8
      class Linking < Abstract
1✔
9
        def initialize(core, subsequent)
1✔
10
          super core, subsequent
255✔
11
          @linked = Set.new
255✔
12
        end
13

14
        def on_envelope(envelope)
1✔
15
          case envelope.message
711✔
16
          when :link
17
            link envelope.sender
2✔
18
          when :unlink
19
            unlink envelope.sender
×
20
          when :linked?
21
            @linked.include? envelope.sender
×
22
          else
23
            pass envelope
709✔
24
          end
25
        end
26

27
        def link(ref)
1✔
28
          @linked.add(ref)
12✔
29
          true
12✔
30
        end
31

32
        def unlink(ref)
1✔
33
          @linked.delete(ref)
×
34
          true
×
35
        end
36

37
        def on_event(event)
1✔
38
          @linked.each { |a| a << event }
274✔
39
          @linked.clear if event == :terminated
257✔
40
          super event
257✔
41
        end
42
      end
43
    end
44
  end
45
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc