Does the compiler simply check which variables are being modified between the lock and unlock statements and bind them to the mutex so there is exclusive access to them?

Or does a `mutex.lock()` lock all resources which are visible in the current scope?