Skip to content

Thread Hazard with Asset Reload #60

Open
@aclysma

Description

@aclysma

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions