HN user

_ko1

44 karma
Posts0
Comments15
View on HN
No posts found.

Thus, you would have to traverse the entire linked data structure to transfer ownership of every node. This is O(n) work.

Correct.

Making things worse, you would have to make sure that the ownership transfer is atomic - no other part of the program should see the data structure in a “partially transferred” state.

Correct. Guild::Channel#transfer_ownership() does it.

Basically, share big linked data with multiple threads is difficult (simply we need to lock every access).

Another example: Say you initially have a guild with three objects, Foo, Bar and Qux, where Foo and Bar point to Qux. If I transfer ownership of Foo, should Qux be transferred as well?

Foo -> Qux; Bar -> Qux

Yes, Qux also moved. Programmer can know by "exception" when accessing Qux via Bar after transfer.

This "realization" is the key of Guild. On threads, we can't realize that Qux is shared mutable.