summaryrefslogtreecommitdiff
path: root/src/VBox/Main/VirtualBoxImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Main/VirtualBoxImpl.cpp')
-rw-r--r--src/VBox/Main/VirtualBoxImpl.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/VBox/Main/VirtualBoxImpl.cpp b/src/VBox/Main/VirtualBoxImpl.cpp
index a57c9d915..b06975f8e 100644
--- a/src/VBox/Main/VirtualBoxImpl.cpp
+++ b/src/VBox/Main/VirtualBoxImpl.cpp
@@ -2420,7 +2420,7 @@ VirtualBox::SVCHelperClientThread(RTTHREAD aThread, void *aUser)
* (pressing the Cancel button to close the Run As dialog) */
if (vrc2 == VERR_CANCELLED)
rc = setError(E_FAIL,
- tr("Operation cancelled by the user"));
+ tr("Operation canceled by the user"));
else
rc = setError(E_FAIL,
tr("Could not launch a privileged process '%s' (%Rrc)"),
@@ -2821,6 +2821,54 @@ void VirtualBox::onGuestPropertyChange(const Guid &aMachineId, IN_BSTR aName,
postEvent(new GuestPropertyEvent(this, aMachineId, aName, aValue, aFlags));
}
+/** Event for onMachineUninit(), this is not a CallbackEvent */
+class MachineUninitEvent : public Event
+{
+public:
+
+ MachineUninitEvent(VirtualBox *aVirtualBox, Machine *aMachine)
+ : mVirtualBox(aVirtualBox), mMachine(aMachine)
+ {
+ Assert(aVirtualBox);
+ Assert(aMachine);
+ }
+
+ void *handler()
+ {
+#ifdef VBOX_WITH_RESOURCE_USAGE_API
+ /* Handle unregistering metrics here, as it is not vital to get
+ * it done immediately. It reduces the number of locks needed and
+ * the lock contention in SessionMachine::uninit. */
+ {
+ AutoWriteLock mLock(mMachine COMMA_LOCKVAL_SRC_POS);
+ mMachine->unregisterMetrics(mVirtualBox->performanceCollector(), mMachine);
+ }
+#endif /* VBOX_WITH_RESOURCE_USAGE_API */
+
+ return NULL;
+ }
+
+private:
+
+ /**
+ * Note that this is a weak ref -- the CallbackEvent handler thread
+ * is bound to the lifetime of the VirtualBox instance, so it's safe.
+ */
+ VirtualBox *mVirtualBox;
+
+ /** Reference to the machine object. */
+ ComObjPtr<Machine> mMachine;
+};
+
+/**
+ * Trigger internal event. This isn't meant to be signalled to clients.
+ * @note Doesn't lock any object.
+ */
+void VirtualBox::onMachineUninit(Machine *aMachine)
+{
+ postEvent(new MachineUninitEvent(this, aMachine));
+}
+
/**
* @note Locks this object for reading.
*/