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

ruby-concurrency / concurrent-ruby / #2835

05 Oct 2014 10:16PM UTC coverage: 45.201% (-49.6%) from 94.81%
#2835

push

jdantonio
Merge pull request #158 from obrok/promise-composition

Promise composition

2 of 15 new or added lines in 1 file covered. (13.33%)

1514 existing lines in 84 files now uncovered.

1375 of 3042 relevant lines covered (45.2%)

0.66 hits per line

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

66.67
/lib/concurrent/actor/reference.rb
1
module Concurrent
1✔
2
  module Actor
1✔
3

4
    # Reference is public interface of Actor instances. It is used for sending messages and can
5
    # be freely passed around the program. It also provides some basic information about the actor,
6
    # see {PublicDelegations}.
7
    class Reference
1✔
8
      include TypeCheck
1✔
9
      include PublicDelegations
1✔
10

11
      attr_reader :core
1✔
12
      private :core
1✔
13

14
      # @!visibility private
15
      def initialize(core)
1✔
UNCOV
16
        @core = Type! core, Core
×
17
      end
18

19
      # tells message to the actor, returns immediately
20
      # @param [Object] message
21
      # @return [Reference] self
22
      def tell(message)
1✔
UNCOV
23
        message message, nil
×
24
      end
25

26
      alias_method :<<, :tell
1✔
27

28
      # @note it's a good practice to use tell whenever possible. Ask should be used only for
29
      # testing and when it returns very shortly. It can lead to deadlock if all threads in
30
      # global_task_pool will block on while asking. It's fine to use it form outside of actors and
31
      # global_task_pool.
32
      #
33
      # sends message to the actor and asks for the result of its processing, returns immediately
34
      # @param [Object] message
35
      # @param [Ivar] ivar to be fulfilled be message's processing result
36
      # @return [IVar] supplied ivar
37
      def ask(message, ivar = IVar.new)
1✔
UNCOV
38
        message message, ivar
×
39
      end
40

41
      # @note it's a good practice to use tell whenever possible. Ask should be used only for
42
      # testing and when it returns very shortly. It can lead to deadlock if all threads in
43
      # global_task_pool will block on while asking. It's fine to use it form outside of actors and
44
      # global_task_pool.
45
      #
46
      # sends message to the actor and asks for the result of its processing, blocks
47
      # @param [Object] message
48
      # @param [Ivar] ivar to be fulfilled be message's processing result
49
      # @return [Object] message's processing result
50
      # @raise [Exception] ivar.reason if ivar is #rejected?
51
      def ask!(message, ivar = IVar.new)
1✔
UNCOV
52
        ask(message, ivar).value!
×
53
      end
54

55
      # behaves as {#tell} when no ivar and as {#ask} when ivar
56
      def message(message, ivar = nil)
1✔
UNCOV
57
        core.on_envelope Envelope.new(message, ivar, Actor.current || Thread.current, self)
×
UNCOV
58
        return ivar || self
×
59
      end
60

61
      # @see AbstractContext#dead_letter_routing
62
      def dead_letter_routing
1✔
UNCOV
63
        core.dead_letter_routing
×
64
      end
65

66
      def to_s
1✔
UNCOV
67
        "#<#{self.class} #{path} (#{actor_class})>"
×
68
      end
69

70
      alias_method :inspect, :to_s
1✔
71

72
      def ==(other)
1✔
UNCOV
73
        Type? other, self.class and other.send(:core) == core
×
74
      end
75

76
      # to avoid confusion with Kernel.spawn
77
      undef_method :spawn
1✔
78
    end
79

80
  end
81
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