mattn / mattn/mruby-thread

Behavior of Thread::new() on passed instances

オープン
#39 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C
スター
49
フォーク
31
PR マージ指標
30日以内にマージされた PR はありません

説明

The original implementation (see also #38) is designed so that Thread.new(a) makes a full copy of a in the newly created thread (unless mrb_type(a) == MRB_TT_DATA).
As a consequence, changes to a in any given thread are not visible to the other threads. This way, passing information between threads becomes a hard task.

Since I am still not sure about the reasons behind this choice, I have made an experimental branch in my own fork (pbosetti/mruby-thread) where the C macro MRB_THREAD_COPY_VALUES can be set to enable the original behavior (make copies) or leave undefined to switch to a "share the same instances" behavior.

The script examples/data.rb can be used to compare the two cases: when MRB_THREAD_COPY_VALUES is set, the changes to globals $data and $ary made in the subthread are not visible into the main thread. Conversely, if MRB_THREAD_COPY_VALUES, any change to instances passed to Thread::new() are visible to other threads.

The question is: can I make a PR for this?

Thanks,
Paolo

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、#38で参照されている元の実装と、実験的なブランチ pbosetti/mruby-thread を読みます。examples/data.rbを使って2つのMRB_THREAD_COPY_VALUESの動作を比較し、共有インスタンスが受け入れられる設計なのか、またThread::newの意図された動作を定義するテストやドキュメントは何かを判断します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c
領域
operating-systems
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。