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

ruby-concurrency / concurrent-ruby / #2764

08 Dec 2014 03:40PM UTC coverage: 91.388% (-0.4%) from 91.753%
#2764

push

jdantonio
Merge pull request #201 from rkday/fallback_handling

Posting to a shutdown thread pool - JRuby consistency and better naming

18 of 26 new or added lines in 5 files covered. (69.23%)

212 existing lines in 36 files now uncovered.

2812 of 3077 relevant lines covered (91.39%)

369.8 hits per line

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

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

5
      # Sets and holds the supervisor of the actor if any. There is at most one supervisor
6
      # for each actor. Each supervisor is automatically linked. Messages:
7
      # `:pause!, :resume!, :reset!, :restart!` are accepted only from supervisor.
8
      class Supervised < Abstract
1✔
9
        attr_reader :supervisor
1✔
10

11
        def initialize(core, subsequent)
1✔
12
          super core, subsequent
14✔
13
          @supervisor = nil
14✔
14
        end
15

16
        def on_envelope(envelope)
1✔
17
          case envelope.message
48✔
18
          when :supervise
19
            supervise envelope.sender
10✔
20
          when :supervisor
21
            supervisor
3✔
22
          when :un_supervise
23
            un_supervise envelope.sender
×
24
          when :pause!, :resume!, :reset!, :restart!
25
            # allow only supervisor to control the actor
26
            if @supervisor == envelope.sender
3✔
27
              pass envelope
3✔
28
            else
UNCOV
29
              false
×
30
            end
31
          else
32
            pass envelope
32✔
33
          end
34
        end
35

36
        def supervise(ref)
1✔
37
          @supervisor = ref
10✔
38
          behaviour!(Linking).link ref
10✔
39
          true
10✔
40
        end
41

42
        def un_supervise(ref)
1✔
UNCOV
43
          if @supervisor == ref
×
UNCOV
44
            behaviour!(Linking).unlink ref
×
UNCOV
45
            @supervisor = nil
×
UNCOV
46
            true
×
47
          else
UNCOV
48
            false
×
49
          end
50
        end
51

52
        def on_event(event)
1✔
53
          @supervisor = nil if event == :terminated
19✔
54
          super event
19✔
55
        end
56
      end
57
    end
58
  end
59
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