A registration handler lock

x::ref<vipnotifyObj> handler;

// ...

  vipintvalue val=*vip_t::readlock(vip);

  vip_t::handlerlock hl(vip);

  hl.install(handler, val);

Use x::vipobj::handlerlock for registering a very important object's callback handler. Instantiating a x::vipobj::handlerlock blocks x::vipobj::updatelocks, but doesn't block other x::vipobj::handlerlocks. Multiple x::vipobj::handlerlocks can get instantiated concurrently.

install() registers a callback handler for the very important object, and immediately invokes it, passing it the given value as the purported initial value of the very important object. The above example acquires a read lock, copies the value of the very important object, releases the read lock, installs the callback handler, immediately invokes it, and returns.

The above example releases the read lock before installing the handler. It's permissible to acquire, and hold, read or write locks, while invoking install(). Of course, that affects the callback handler's own access to the very important object. Additionally, nothing prevents other threads from acquiring their own read and write locks, and accessing the very important object while the handler lock remains in scope. The handler lock only blocks update locks. After the handler lock goes out of scope, official changes to the very important object get reported to the installed handler by instantiating update locks and invoking their notify() methods.