Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you're calling back into user code, you need to reestablish invariants first.

As for threading, C++ distinguishes mutating from non mutating (const) methods. Usually, any number of threads can call const methods simultaneously, but only one thread can have access if mutating methods are called. This may require external synchronisation.

The optimizer is often capable of inferring when invariants are maintained. One controversy is whether it should be permitted to use contracted invariants as axiomatic.



The compiler can't reliably make assumptions about whether const methods in C++ cause mutation, because both const_cast and aliasing are permitted.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: