/** @short implements a guard, which can use the interface <typescope="css::document">XActionLockable</type>.
@descrThisguardshouldbeusedtobesure,thatanylockwillbe released.Otherwisethelockeddocumentcanhindertheofficeonshutdown!
*/ class ActionLockGuard final
{
// member
private:
std::mutex m_mutex;
/** @short points to the object, which can be locked from outside. */
css::uno::Reference< css::document::XActionLockable > m_xActionLock;
/** @short knows if a lock exists on the internal lock object
forced by this guard instance. */ bool m_bActionLocked;
// interface
public:
/** @short default ctor to initialize a "non working guard".
/** @short release this guard instance and make sure, that no lock willexistafterwardsontheinternalwrappedresource.
*/
~ActionLockGuard()
{
unlock();
}
/** @short set a new resource for locking at this guard.
if (bLocked && xLock.is())
xLock->removeActionLock();
}
/** @short unlock the internal wrapped resource, if it's not already done. */ void unlock()
{
std::unique_lock g(m_mutex); if (m_bActionLocked && m_xActionLock.is())
{
m_xActionLock->removeActionLock(); // don't check for any locks here ... // May another guard use the same lock object :-(
m_bActionLocked = false;
}
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.