status_t BMessenger::LockTargetWithTimeout(bigtime_t timeout) const { BLooper* looper = NULL; Target(&looper); if (looper == NULL) return B_BAD_VALUE; status_t result = looper->LockWithTimeout(timeout); if (result == B_OK && looper->fMsgPort != fPort) { looper->Unlock(); return B_BAD_PORT_ID; } return result; }
status_t BHandler::LockLooperWithTimeout(bigtime_t timeout) { BLooper* looper = fLooper; if (looper == NULL) return B_BAD_VALUE; status_t status = looper->LockWithTimeout(timeout); if (status != B_OK) return status; if (fLooper != looper) { // we locked the wrong looper, bail out looper->Unlock(); return B_MISMATCHED_VALUES; } return B_OK; }