[folks: 1/3] inspect: Make Command.run async. inspect: Make linking folks-inspect command run not return until do
- From: Jeremy Whiting <jpwhiting src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks: 1/3] inspect: Make Command.run async. inspect: Make linking folks-inspect command run not return until do
- Date: Wed, 5 Sep 2012 22:38:00 +0000 (UTC)
commit 0434d197a9ba43eade74787a9a8ba065c3dfb861
Author: Jeremy Whiting <jpwhiting kde org>
Date: Fri Aug 3 15:23:11 2012 -0600
inspect: Make Command.run async.
inspect: Make linking folks-inspect command run not return until done.
tools/inspect/command-backends.vala | 2 +-
tools/inspect/command-debug.vala | 2 +-
tools/inspect/command-help.vala | 2 +-
tools/inspect/command-individuals.vala | 2 +-
tools/inspect/command-linking.vala | 64 +++++++++++++----------------
tools/inspect/command-persona-stores.vala | 2 +-
tools/inspect/command-personas.vala | 2 +-
tools/inspect/command-quit.vala | 2 +-
tools/inspect/command-signals.vala | 2 +-
tools/inspect/inspect.vala | 57 +++++++++++++-------------
10 files changed, 66 insertions(+), 71 deletions(-)
---
diff --git a/tools/inspect/command-backends.vala b/tools/inspect/command-backends.vala
index db28ed2..5f2564e 100644
--- a/tools/inspect/command-backends.vala
+++ b/tools/inspect/command-backends.vala
@@ -49,7 +49,7 @@ private class Folks.Inspect.Commands.Backends : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
if (command_string == null)
{
diff --git a/tools/inspect/command-debug.vala b/tools/inspect/command-debug.vala
index 86de9c2..8cc3e6a 100644
--- a/tools/inspect/command-debug.vala
+++ b/tools/inspect/command-debug.vala
@@ -46,7 +46,7 @@ private class Folks.Inspect.Commands.Debug : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
var debug = Folks.Debug.dup ();
debug.emit_print_status ();
diff --git a/tools/inspect/command-help.vala b/tools/inspect/command-help.vala
index 21d3b03..b2e5f2c 100644
--- a/tools/inspect/command-help.vala
+++ b/tools/inspect/command-help.vala
@@ -50,7 +50,7 @@ private class Folks.Inspect.Commands.Help : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
if (command_string == null)
{
diff --git a/tools/inspect/command-individuals.vala b/tools/inspect/command-individuals.vala
index 2c0c97b..019f861 100644
--- a/tools/inspect/command-individuals.vala
+++ b/tools/inspect/command-individuals.vala
@@ -53,7 +53,7 @@ private class Folks.Inspect.Commands.Individuals : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
if (command_string == null)
{
diff --git a/tools/inspect/command-linking.vala b/tools/inspect/command-linking.vala
index beb9c62..366f13b 100644
--- a/tools/inspect/command-linking.vala
+++ b/tools/inspect/command-linking.vala
@@ -58,7 +58,7 @@ private class Folks.Inspect.Commands.Linking : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
string[] parts = {};
@@ -178,27 +178,24 @@ private class Folks.Inspect.Commands.Linking : Folks.Inspect.Command
}
/* Link the personas */
- this.client.aggregator.link_personas.begin (personas, (obj, res) =>
+ try
{
- try
- {
- this.client.aggregator.link_personas.end (res);
- }
- catch (IndividualAggregatorError e)
- {
- Utils.print_line ("Error (domain: %u, code: %u) linking %u " +
- "personas: %s",
- e.domain, e.code, personas.size, e.message);
- }
+ yield this.client.aggregator.link_personas (personas);
+ }
+ catch (IndividualAggregatorError e)
+ {
+ Utils.print_line ("Error (domain: %u, code: %u) linking %u " +
+ "personas: %s",
+ e.domain, e.code, personas.size, e.message);
+ }
- /* We can't print out the individual which was produced, as
- * more than one may have been produced (due to anti-links)
- * or several others may have been consumed in the process.
- *
- * Chaos, really. */
- Utils.print_line ("Linking of %u personas was successful.",
- personas.size);
- });
+ /* We can't print out the individual which was produced, as
+ * more than one may have been produced (due to anti-links)
+ * or several others may have been consumed in the process.
+ *
+ * Chaos, really. */
+ Utils.print_line ("Linking of %u personas was successful.",
+ personas.size);
}
else if (parts[0] == "unlink-individual")
{
@@ -218,23 +215,20 @@ private class Folks.Inspect.Commands.Linking : Folks.Inspect.Command
}
/* Unlink the individual. */
- this.client.aggregator.unlink_individual.begin (ind, (obj, res) =>
+ try
{
- try
- {
- this.client.aggregator.unlink_individual.end (res);
- }
- catch (Error e)
- {
- Utils.print_line ("Error (domain: %u, code: %u) unlinking " +
- "individual '%s': %s",
- e.domain, e.code, ind.id, e.message);
- }
+ yield this.client.aggregator.unlink_individual (ind);
+ }
+ catch (Error e)
+ {
+ Utils.print_line ("Error (domain: %u, code: %u) unlinking " +
+ "individual '%s': %s",
+ e.domain, e.code, ind.id, e.message);
+ }
- /* Success! */
- Utils.print_line ("Unlinking of individual '%s' was successful.",
- ind.id);
- });
+ /* Success! */
+ Utils.print_line ("Unlinking of individual '%s' was successful.",
+ ind.id);
}
else
{
diff --git a/tools/inspect/command-persona-stores.vala b/tools/inspect/command-persona-stores.vala
index 40368b4..c8b28a8 100644
--- a/tools/inspect/command-persona-stores.vala
+++ b/tools/inspect/command-persona-stores.vala
@@ -53,7 +53,7 @@ private class Folks.Inspect.Commands.PersonaStores : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
if (command_string == null)
{
diff --git a/tools/inspect/command-personas.vala b/tools/inspect/command-personas.vala
index 8c06a4a..121ace6 100644
--- a/tools/inspect/command-personas.vala
+++ b/tools/inspect/command-personas.vala
@@ -52,7 +52,7 @@ private class Folks.Inspect.Commands.Personas : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
foreach (var individual in this.client.aggregator.individuals.values)
{
diff --git a/tools/inspect/command-quit.vala b/tools/inspect/command-quit.vala
index 7999507..4b5eb62 100644
--- a/tools/inspect/command-quit.vala
+++ b/tools/inspect/command-quit.vala
@@ -50,7 +50,7 @@ private class Folks.Inspect.Commands.Quit : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
Process.exit (0);
}
diff --git a/tools/inspect/command-signals.vala b/tools/inspect/command-signals.vala
index 6f57dfc..72b790a 100644
--- a/tools/inspect/command-signals.vala
+++ b/tools/inspect/command-signals.vala
@@ -94,7 +94,7 @@ private class Folks.Inspect.Commands.Signals : Folks.Inspect.Command
base (client);
}
- public override void run (string? command_string)
+ public override async void run (string? command_string)
{
if (command_string == null)
{
diff --git a/tools/inspect/inspect.vala b/tools/inspect/inspect.vala
index a8f4573..f480151 100644
--- a/tools/inspect/inspect.vala
+++ b/tools/inspect/inspect.vala
@@ -93,7 +93,7 @@ public class Folks.Inspect.Client : Object
/* Run the command. */
if (args.length == 1)
{
- main_client.run_interactive ();
+ main_client.run_interactive.begin ();
}
else
{
@@ -112,8 +112,14 @@ public class Folks.Inspect.Client : Object
command_line = string.joinv (" ", args[1:0]);
}
- main_client.run_non_interactive (command_line);
+ main_client.run_non_interactive.begin (command_line, (obj, res) =>
+ {
+ main_client.run_non_interactive.end (res);
+ main_client.quit ();
+ });
}
+
+ main_client.main_loop.run ();
return 0;
}
@@ -195,7 +201,7 @@ public class Folks.Inspect.Client : Object
}
}
- public void run_non_interactive (string command_line)
+ public async void run_non_interactive (string command_line)
{
/* Non-interactive mode: run a single command and output the results.
* We do this all from the main thread, in a main loop, waiting for
@@ -215,28 +221,22 @@ public class Folks.Inspect.Client : Object
/* Wait until we reach quiescence, or the results will probably be
* useless. */
- this._wait_for_quiescence.begin ((obj, res) =>
+ try
{
- try
- {
- this._wait_for_quiescence.end (res);
- }
- catch (GLib.Error e1)
- {
- GLib.stderr.printf ("Error preparing aggregator: %s\n", e1.message);
- Process.exit (1);
- }
-
- /* Run the command */
- command.run (subcommand);
-
- this.quit ();
- });
+ yield this._wait_for_quiescence ();
+ }
+ catch (GLib.Error e1)
+ {
+ GLib.stderr.printf ("Error preparing aggregator: %s\n", e1.message);
+ Process.exit (1);
+ }
- this.main_loop.run ();
+ /* Run the command */
+ yield command.run (subcommand);
+ this.quit ();
}
- public void run_interactive ()
+ public async void run_interactive ()
{
/* Interactive mode: have a little shell which allows the data from
* libfolks to be browsed and edited in real time. We do this by watching
@@ -285,8 +285,6 @@ public class Folks.Inspect.Client : Object
/* Run the aggregator and the main loop. */
this.aggregator.prepare.begin ();
-
- this.main_loop.run ();
}
private void _install_readline_and_stdin ()
@@ -365,11 +363,14 @@ public class Folks.Inspect.Client : Object
main_client._start_paged_output ();
}
- command.run (subcommand);
+ command.run.begin (subcommand, (obj, res) =>
+ {
+ command.run.end (res);
+ /* Close the stream to the pager so it knows it's reached EOF. */
+ main_client._pager_channel = null;
+ Utils.output_filestream = GLib.stdout;
+ });
- /* Close the stream to the pager so it knows it's reached EOF. */
- main_client._pager_channel = null;
- Utils.output_filestream = GLib.stdout;
}
else
{
@@ -571,7 +572,7 @@ public abstract class Folks.Inspect.Command
public abstract string description { get; }
public abstract string help { get; }
- public abstract void run (string? command_string);
+ public abstract async void run (string? command_string);
public virtual string[]? complete_subcommand (string subcommand)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]