AtomicBoolean: add compare_and_set API
まだ誰も着手していません。
評価
調査の方向性
Start by locating the AtomicBoolean implementation and its current value API. Review how the existing atomic value behavior is tested, then determine where the compare_and_set entry point belongs. Done means the proposed API supports the false-to-true use case described in the issue and its behavior is covered by the project’s tests.
索引モデルが issue の本文から書いたものです。
説明
Compare-and-set is a useful functionality (that's why it exists in the Java API). It can save one from race conditions, as explained below.
Use case
- Assume an atomicboolean called
LOCKED, set to false. - Multiple concurrent threads run the following code:
if !LOCKED.value
LOCKED.value = true
# do something ....
LOCKED.value = false
end
In this scenario, concurrent threads can read a false in if !LOCKED.value, and enter the if block. That defeats the purpose of an atomicboolean-backed lock.
If there was a CAS API, the fixed code would look like this:
if LOCKED.compare_and_set(false, true)
Furthermore
Ruby has no "tryLock" either. So it's not immediately obvious how to create non-blocking synchronized code. Boolean CAS would offer a nice alternative which Java programmers (and others) already are familiar with.
What do you think?
Cheers - Victor
- 主要言語
- Ruby
- スター
- 5.8k
- フォーク
- 420
- 平均マージ
- 20時間 45分
- マージ済み PR(30日)
- 4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby-concurrency/concurrent-ruby のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
ruby-concurrency/concurrent-ruby#1118 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
ruby-concurrency/concurrent-ruby#1099 · コメント 9 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
ruby-concurrency/concurrent-ruby#1095 · コメント 8 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
ruby-concurrency/concurrent-ruby#1093 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
ruby-concurrency/concurrent-ruby#1091 ·
ruby-concurrency/concurrent-ruby の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
バグ
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
voxpupuli/puppet-epel#186 · コメント 1 件 ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) オープンBug Frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100