mattn / mattn/mruby-thread

Behavior of Thread::new() on passed instances

Aperta
#39 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C
Stelle
49
Fork
31
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo l’implementazione originale referenziata in #38 e il branch sperimentale pbosetti/mruby-thread. Confronta i due comportamenti di MRB_THREAD_COPY_VALUES usando examples/data.rb, quindi determina se le istanze condivise sono un design accettato e quali test o documentazione definirebbero il comportamento previsto di Thread::new.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c
Ambito
operating-systems
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.