pub struct Device<A: HalApi> { /* private fields */ }
Expand description
Structure describing a logical device. Some members are internally mutable, stored behind mutexes.
TODO: establish clear order of locking for these:
life_tracker
, trackers
, render_passes
, pending_writes
, trace
.
Currently, the rules are:
life_tracker
is locked afterhub.devices
, enforced by the type systemself.trackers
is locked last (unenforced)self.trace
is locked last (unenforced)
Right now avoid locking twice same resource or registry in a call execution and minimize the locking to the minimum scope possibile Unless otherwise specified, no lock may be acquired while holding another lock. This means that you must inspect function calls made while a lock is held to see what locks the callee may try to acquire.
As far as this point: device_maintain_ids locks Device::lifetime_tracker, and calls… triage_suspected locks Device::trackers, and calls… Registry::unregister locks Registry::storage
Important: When locking pending_writes please check that trackers is not locked trackers should be locked only when needed for the shortest time possible