Something like boost::unique_lock lock(my_lockable, boost::try_to_lock);
should do the trick.
lock.owns_lock()
will return true if the lock were acquired. If it wasn't acquired you should not attempt to release it.
It should always be safe to call notify_one
even if no condition is waiting for it.