diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a865b48b3..0f6450e5c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -66,7 +66,7 @@ There are a few guidelines which we follow when adding features. Consider that s #### Write Documentation -Document any external behavior in the [README](README.md). +Document any external behavior in the [README](../README.md). #### Commit Changes @@ -106,7 +106,7 @@ git push origin my-feature-branch -f #### Update CHANGELOG -Update the [CHANGELOG](CHANGELOG.md) with a description of what you have changed. +Update the [CHANGELOG](../CHANGELOG.md) with a description of what you have changed. #### Check on Your Pull Request diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab1d23db8..b5724f575 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,16 +6,17 @@ concurrency: jobs: build: + name: "Tests: Ruby ${{ matrix.ruby }} - ${{ matrix.os }}" runs-on: ${{ matrix.os }}-latest timeout-minutes: 10 strategy: fail-fast: false matrix: - ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby, truffleruby] + ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4, jruby, truffleruby] os: [ubuntu] include: - - ruby: 3.3 + - ruby: ruby os: windows env: @@ -23,10 +24,9 @@ jobs: RUBYOPT: '-w' JRUBY_OPTS: '--dev' - name: "Tests: Ruby ${{ matrix.ruby }} - ${{ matrix.os }}" steps: - name: Clone Repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: @@ -35,6 +35,21 @@ jobs: - name: Run tests run: bundle exec rake ci + no-extensions: + name: "Test without C extension" + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + RUBYOPT: '-w' + steps: + - uses: actions/checkout@v5 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby + bundler-cache: true + - name: Run tests + run: bundle exec rake spec:ci + isolated: name: "Test isolated" runs-on: ubuntu-latest @@ -46,7 +61,7 @@ jobs: env: RUBYOPT: '-w' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 780f0741c..2ed493ffb 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,7 +18,7 @@ jobs: env: BUNDLE_WITH: "documentation" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - uses: ruby/setup-ruby@v1 @@ -29,7 +29,7 @@ jobs: - run: ruby support/generate_docs.rb - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: docs diff --git a/.github/workflows/experimental.yml b/.github/workflows/experimental.yml index 28048747c..d31d54be9 100644 --- a/.github/workflows/experimental.yml +++ b/.github/workflows/experimental.yml @@ -21,7 +21,7 @@ jobs: name: "Tests: Experimental Ruby ${{ matrix.ruby }}" steps: - name: Clone Repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: diff --git a/README.md b/README.md index 63ee743c5..6635e815a 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,7 @@ Deprecated features are still available and bugs are being fixed, but new featur These are available in the `concurrent-ruby-edge` companion gem. These features are under active development and may change frequently. They are expected not to -keep backward compatibility (there may also lack tests and documentation). Semantic versions will +keep backward compatibility (they may also lack tests and documentation). Semantic versions will be obeyed though. Features developed in `concurrent-ruby-edge` are expected to move to `concurrent-ruby` when final. @@ -358,7 +358,8 @@ best practice is to depend on `concurrent-ruby` and let users to decide if they * Recent CRuby * JRuby, `rbenv install jruby-9.2.17.0` * Set env variable `CONCURRENT_JRUBY_HOME` to point to it, e.g. `/usr/local/opt/rbenv/versions/jruby-9.2.17.0` -* Install Docker, required for Windows builds +* Install Docker or Podman, required for Windows builds +* If `bundle config get path` is set, use `bundle config set --local path.system true` otherwise the `gem name, path: '.'` gems won't be found (Bundler limitation). ### Publishing the Gem diff --git a/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb b/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb index ebf23a241..c367d2622 100644 --- a/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb +++ b/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb @@ -6,6 +6,7 @@ module Concurrent # @!visibility private def self.mutex_owned_per_thread? return false if Concurrent.on_jruby? || Concurrent.on_truffleruby? + return RUBY_VERSION < "3.0" if Concurrent.on_cruby? mutex = Mutex.new # Lock the mutex: diff --git a/lib/concurrent-ruby/concurrent/mvar.rb b/lib/concurrent-ruby/concurrent/mvar.rb index dfc41950c..9777ba347 100644 --- a/lib/concurrent-ruby/concurrent/mvar.rb +++ b/lib/concurrent-ruby/concurrent/mvar.rb @@ -9,7 +9,7 @@ module Concurrent # queue of length one, or a special kind of mutable variable. # # On top of the fundamental `#put` and `#take` operations, we also provide a - # `#mutate` that is atomic with respect to operations on the same instance. + # `#modify` that is atomic with respect to operations on the same instance. # These operations all support timeouts. # # We also support non-blocking operations `#try_put!` and `#try_take!`, a @@ -87,7 +87,7 @@ def borrow(timeout = nil) @mutex.synchronize do wait_for_full(timeout) - # if we timeoud out we'll still be empty + # If we timed out we'll still be empty if unlocked_full? yield @value else @@ -116,10 +116,10 @@ def put(value, timeout = nil) end # Atomically `take`, yield the value to a block for transformation, and then - # `put` the transformed value. Returns the transformed value. A timeout can + # `put` the transformed value. Returns the pre-transform value. A timeout can # be set to limit the time spent blocked, in which case it returns `TIMEOUT` # if the time is exceeded. - # @return [Object] the transformed value, or `TIMEOUT` + # @return [Object] the pre-transform value, or `TIMEOUT` def modify(timeout = nil) raise ArgumentError.new('no block given') unless block_given? diff --git a/lib/concurrent-ruby/concurrent/promise.rb b/lib/concurrent-ruby/concurrent/promise.rb index c717f9b0d..8df80b0c7 100644 --- a/lib/concurrent-ruby/concurrent/promise.rb +++ b/lib/concurrent-ruby/concurrent/promise.rb @@ -167,7 +167,7 @@ module Concurrent # c2 = p.then(-> reason { raise 'Boom!' }) # # c1.wait.state #=> :fulfilled - # c1.value #=> 45 + # c1.value #=> 42 # c2.wait.state #=> :rejected # c2.reason #=> # # ``` diff --git a/spec/concurrent/atomic/atomic_boolean_spec.rb b/spec/concurrent/atomic/atomic_boolean_spec.rb index 133b7f2ce..76edd3e27 100644 --- a/spec/concurrent/atomic/atomic_boolean_spec.rb +++ b/spec/concurrent/atomic/atomic_boolean_spec.rb @@ -142,7 +142,7 @@ module Concurrent end end - if Concurrent.allow_c_extensions? + if Concurrent.c_extensions_loaded? RSpec.describe CAtomicBoolean do it_should_behave_like :atomic_boolean end @@ -165,7 +165,7 @@ module Concurrent it 'inherits from JavaAtomicBoolean' do expect(AtomicBoolean.ancestors).to include(JavaAtomicBoolean) end - elsif Concurrent.allow_c_extensions? + elsif Concurrent.c_extensions_loaded? it 'inherits from CAtomicBoolean' do expect(AtomicBoolean.ancestors).to include(CAtomicBoolean) end diff --git a/spec/concurrent/atomic/atomic_fixnum_spec.rb b/spec/concurrent/atomic/atomic_fixnum_spec.rb index 39259b13f..8222bf523 100644 --- a/spec/concurrent/atomic/atomic_fixnum_spec.rb +++ b/spec/concurrent/atomic/atomic_fixnum_spec.rb @@ -204,7 +204,7 @@ module Concurrent end end - if Concurrent.allow_c_extensions? + if Concurrent.c_extensions_loaded? RSpec.describe CAtomicFixnum do it_should_behave_like :atomic_fixnum end @@ -227,7 +227,7 @@ module Concurrent it 'inherits from JavaAtomicFixnum' do expect(AtomicFixnum.ancestors).to include(JavaAtomicFixnum) end - elsif Concurrent.allow_c_extensions? + elsif Concurrent.c_extensions_loaded? it 'inherits from CAtomicFixnum' do expect(AtomicFixnum.ancestors).to include(CAtomicFixnum) end diff --git a/spec/concurrent/atomic/atomic_reference_spec.rb b/spec/concurrent/atomic/atomic_reference_spec.rb index 2cc0caada..7eaf2e55e 100644 --- a/spec/concurrent/atomic/atomic_reference_spec.rb +++ b/spec/concurrent/atomic/atomic_reference_spec.rb @@ -163,7 +163,7 @@ module Concurrent it_should_behave_like :atomic_reference end - if Concurrent.allow_c_extensions? + if Concurrent.c_extensions_loaded? RSpec.describe CAtomicReference do it_should_behave_like :atomic_reference end @@ -190,7 +190,7 @@ module Concurrent it 'inherits from JavaAtomicReference' do expect(described_class.ancestors).to include(Concurrent::JavaAtomicReference) end - elsif Concurrent.allow_c_extensions? + elsif Concurrent.c_extensions_loaded? it 'inherits from CAtomicReference' do expect(described_class.ancestors).to include(Concurrent::CAtomicReference) end