[gnome-boxes/gnome-3-4] Remove some more sync calls to GVir.Domain.get_info()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/gnome-3-4] Remove some more sync calls to GVir.Domain.get_info()
- Date: Mon, 14 May 2012 20:49:51 +0000 (UTC)
commit 12d722a3f8b31e509288d420bddfd34af145ffab
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue May 8 00:48:57 2012 +0300
Remove some more sync calls to GVir.Domain.get_info()
This is a blocking call so remove calls where redundant or make it
async in hot (enough) paths.
https://bugzilla.gnome.org/show_bug.cgi?id=674352
src/libvirt-machine.vala | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 142c248..d28e2cc 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -137,14 +137,14 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
private void update_mem_stat (DomainInfo info, ref MachineStat stat) {
- if (!is_running ())
+ if (info.state != DomainState.RUNNING)
return;
stat.memory_percent = info.memory * 100.0 / info.maxMem;
}
- private void update_io_stat (ref MachineStat stat) {
- if (!is_running ())
+ private void update_io_stat (DomainInfo info, ref MachineStat stat) {
+ if (info.state != DomainState.RUNNING)
return;
try {
@@ -163,8 +163,8 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
}
- private void update_net_stat (ref MachineStat stat) {
- if (!is_running ())
+ private void update_net_stat (DomainInfo info, ref MachineStat stat) {
+ if (info.state != DomainState.RUNNING)
return;
try {
@@ -196,8 +196,8 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
update_cpu_stat (info, ref stat);
update_mem_stat (info, ref stat);
- update_io_stat (ref stat);
- update_net_stat (ref stat);
+ update_io_stat (info, ref stat);
+ update_net_stat (info, ref stat);
stats = stats[1:STATS_SIZE];
stats += stat;
@@ -318,8 +318,14 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
public override async bool take_screenshot () throws GLib.Error {
- if (state != DomainState.RUNNING &&
- state != DomainState.PAUSED)
+ var state = DomainState.NONE;
+ try {
+ state = (yield domain.get_info_async (null)).state;
+ } catch (GLib.Error error) {
+ warning ("Failed to get information on '%s'", name);
+ }
+
+ if (state != DomainState.RUNNING && state != DomainState.PAUSED)
return true;
var stream = connection.get_stream (0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]