I'm trying to write a program that will eventually run concurrently on multiple cores.
I have a dataset that consists of multiple files, and I'd like to parallelize loading the data.
That lets me load data in parallel.
Later on I'd also like to do other operations on my data in parallel. I quickly learned that I can't write a getter that returns a reference to a single DataItem when the definition above is used. After thinking about it a bit, that seems correct.
I can make that work if I change the struct definition to this:
I think I'll go with the idea from @RedDocMD for now.
That way I can attach relevant manipulation methods to the wrapping struct and hide the locking from callers.