Struct coap_message_demos::cbor::TryingThroughMutex [−][src]
pub struct TryingThroughMutex<T: SimpleCBORHandler>(pub Arc<Mutex<T>>);
Expand description
Helper struct that accesses a SimpleCBORHandler intrough an Arc<Mutex<_>>
, thus allowing easiy
simultaneous access.
When implementing SimpelCBORHandler, it does not wait for the lock, but rather fails with a 5.03 Service Unavailable that usually prompts the client to retry. Note that this will not happen ever if the items are just accessed through different paths on the same handler, and neither will be if they are only ever locked outside the CoAP server’s main loop. (And even then, unless they’re locked for long, it’s very unlikely to be hit by chance).
TBD: Send a “Max-Age: 0” option along to indicate that the client can try again right away rather than wait the usual 60 seconds.
TBD: This may be a nice addition to the coap_handler crate in general (but needs the
introduction of a std
feature there).
Tuple Fields
0: Arc<Mutex<T>>