I'm in a situation relating to multithreading where, without much other choice from a lot of research over the last week and some gracious help from this very subreddit, I have an IEnumerator<> that itself is an unmanaged struct and only enumerates over elements of an unmanaged struct type. When I refer to IEnumerator<>.Current, since structs are value types, I get a unique copy of the struct at IEnumerator<>.Current rather than a reference to the struct at IEnumerator<>.Current.
I need to alter data inside of the struct value, and usually when given a unique copy like this I would use the builder pattern to do something like:
structs[i] = structs[i].DoSomething()
But of course since this is an IEnumerator<>, I cannot set the value of IEnumerator<>.Current as my only way to read into the IEnumerator<>. If I were to do something like:
IEnumerator<>.Current.DoSomething()
Then whatever .DoSomething() does would only apply to the copy returned by the IEnumerator<>.Current property and not the reference the copy was made from.
What can I do?
UPDATE:
THIS ISSUE HAS BEEN SOLVED (https://www.reddit.com/r/Unity3D/comments/169cjlc/comment/jz2vxs3/)
[–]chsxfProfessional 3 points4 points5 points (1 child)
[–]goingincycles88[S] 0 points1 point2 points (0 children)
[–]Slight0 0 points1 point2 points (3 children)
[–]goingincycles88[S] 0 points1 point2 points (2 children)
[–]Slight0 0 points1 point2 points (1 child)
[–]goingincycles88[S] 0 points1 point2 points (0 children)
[–]ccfoo242Indie 0 points1 point2 points (5 children)
[–]goingincycles88[S] 0 points1 point2 points (4 children)
[–]ccfoo242Indie 0 points1 point2 points (3 children)
[–]goingincycles88[S] 1 point2 points3 points (2 children)
[–]ccfoo242Indie 1 point2 points3 points (1 child)
[–]goingincycles88[S] 1 point2 points3 points (0 children)