Fixing error when an instance of custom class is given to Thread#new#38
Merged
Conversation
Conflicts: src/mrb_thread.c
…rived from Object The original error says: "TypeError: wrong argument type NameError (expected Class)". Added an example/data.rb to illustrate the problem. original code raising the exception is commented out.
Owner
|
Thanks. Btw, data.rb seems broken to me. shoud be count-up but not. (not depend on your change. this maybe my bug) |
Contributor
Author
|
@mattn that is exactly the point: from what I understand, it is not counting up because the two threads are operating on different copies of the original object. If you replace lines 235 and 236 with: nv = v;then I hope that my point (and my question) is clear. |
Contributor
|
Hi @pbosetti add Makefile is need? this Makefile not run. because you remove run_test.rb. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you use the
example/data.rbwith the original source, you get a TypeError error onThread#newcall. This commit seems to solve it.Related to this, I note here that the only working ways to exchange data among threads that I have found are:
Queue, and put what you want to exchange as an instance variable ofQueue.MRB_TT_DATAin general (the sameQueueis aMRB_TT_DATA)So my question is: would it be dangerous/unadvisable to use the same
vn = vassignment for all the data types inmigrate_simple_value(), rather than make empty copies that start having different lives in different threads? I feel that having threads and not being able to share data among them is a large limitation, but perhaps there are some GC-related issues that rule out this possibility.Any insight?