Yes, I think the second should prevent boxing the lock, so it will be passed as just the atomic ref. As for the first sample: only because the function itself is also inlined, I think the compiler could theoretically avoid boxing. But I have no idea if it does this in practice or unfortunately, it isn’t smart enough and it boxes the lock. If the function is not inlined and accepts Lock, the compiler has to box.
2 Likes