ruby-concurrency / ruby-concurrency/concurrent-ruby
AtomicBoolean: add compare_and_set API
まだ誰も着手していません。
- 主要言語
- Ruby
- スター
- 5.8k
- フォーク
- 420
- 平均マージ
- 20時間 45分
- マージ済み PR(30日)
- 4
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
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 の本文から書いたものです。
評価
- 技術スタック
- ruby
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100