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

ruby-concurrency / concurrent-ruby / #2937

05 Oct 2014 10:16PM UTC coverage: 90.686% (-4.1%) from 94.81%
#2937

push

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

Promise composition

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

145 existing lines in 16 files now uncovered.

2775 of 3060 relevant lines covered (90.69%)

316.23 hits per line

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

50.0
/lib/concurrent/atomic/synchronization.rb
1
module Concurrent
1✔
2

3
  # Safe synchronization under JRuby, prevents reading uninitialized @mutex variable.
4
  # @note synchronized needs to be called in #initialize for this module to work properly
5
  # @example usage
6
  #     class AClass
7
  #       include Synchronized
8
  #
9
  #       def initialize
10
  #         synchronize do
11
  #           # body of the constructor ...
12
  #         end
13
  #       end
14
  #
15
  #       def a_method
16
  #         synchronize do
17
  #           # body of a_method ...
18
  #         end
19
  #       end
20
  #     end
21
  module Synchronization
1✔
22

23
    engine = defined?(RUBY_ENGINE) && RUBY_ENGINE
1✔
24

25
    case engine
1✔
26
    when 'jruby'
UNCOV
27
      require 'jruby'
×
28

UNCOV
29
      def synchronize
×
UNCOV
30
        JRuby.reference0(self).synchronized { yield }
×
31
      end
32

33
    when 'rbx'
34

UNCOV
35
      def synchronize
×
UNCOV
36
        Rubinius.lock(self)
×
UNCOV
37
        yield
×
38
      ensure
UNCOV
39
        Rubinius.unlock(self)
×
40
      end
41

42
    else
43

44
      def synchronize
1✔
45
        @mutex ||= Mutex.new
8,150✔
46
        @mutex.synchronize { yield }
16,300✔
47
      end
48

49
    end
50
  end
51
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