Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread Hazard with Asset Reload #60

Open
aclysma opened this issue Oct 27, 2013 · 0 comments
Open

Thread Hazard with Asset Reload #60

aclysma opened this issue Oct 27, 2013 · 0 comments

Comments

@aclysma
Copy link
Member

aclysma commented Oct 27, 2013

The object and proxy point to each other and maintain a ref count. We swap two pointers when swapping assets. There is a hazard that another thread could modify the reference counts on a proxy that no longer matches the object.

A potential solution is to have a global sync point for all threads every frame and do asset swaps during that sync. We could have a flag and a counter for threads that actively use the reference counting. A thread wanting to do a swap could add the swap to a list and set the flag. All threads would eventually need to sync, and when they see the flag, they would decrement their count and wait. The thread that decrements to zero would then do the swap and signal all other threads to start again, possibly with a condition.

We will need to take care that posix and windows threads have consistent behavior and ensure that all threads resume again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant