| ▲ | jstimpfle 7 hours ago | |||||||
Initialization is always special. A mutex can't protect that which doesn't exist yet. The right way to initialize your object would be to construct the message first, then construct the composite type that combines the message with a mutex. This doesn't require locking a mutex, even without any borrow checker or other cleverness. | ||||||||
| ▲ | adwn 7 hours ago | parent [-] | |||||||
Dude, it's a simplified example, of course you can poke holes into it. Here, let me help you fill in the gaps:
The point is, that there are situations where you have exclusive access to a mutex, and in those situations you can safely access the protected data without having to lock the mutex. | ||||||||
| ||||||||