[Fawkes Git] branch/bschaepers/asp-aspect: ASP-Aspect: Add ability to start solving not async.

Bjoern Schaepers bjoern.schaepers at rwth-aachen.de
Sat Nov 26 18:12:33 CET 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, bschaepers/asp-aspect has been updated
        to  07374426b1c53acc9510a7375fbcc54646810c33 (commit)
      from  2d2427904bcf3ce87ee43a25405e178704dd3683 (commit)

http://git.fawkesrobotics.org/fawkes.git/bschaepers/asp-aspect

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit 07374426b1c53acc9510a7375fbcc54646810c33
Author:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
AuthorDate: Sat Nov 26 18:11:52 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
CommitDate: Sat Nov 26 18:11:52 2016 +0100

    ASP-Aspect: Add ability to start solving not async.

http://git.fawkesrobotics.org/fawkes.git/commit/0737442
http://trac.fawkesrobotics.org/changeset/0737442

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/plugins/asp/aspect/clingo_access.cpp |   32 +++++++++++++++++++++++++++++-
 src/plugins/asp/aspect/clingo_access.h   |    1 +
 2 files changed, 32 insertions(+), 1 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* 07374426b1c53acc9510a7375fbcc54646810c33 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaepers at rwth-aachen.de>
Date:    Sat Nov 26 18:11:52 2016 +0100
Subject: ASP-Aspect: Add ability to start solving not async.

 src/plugins/asp/aspect/clingo_access.cpp |   32 +++++++++++++++++++++++++++++-
 src/plugins/asp/aspect/clingo_access.h   |    1 +
 2 files changed, 32 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/asp/aspect/clingo_access.cpp b/src/plugins/asp/aspect/clingo_access.cpp
index 63bddaf..3117f04 100644
--- a/src/plugins/asp/aspect/clingo_access.cpp
+++ b/src/plugins/asp/aspect/clingo_access.cpp
@@ -248,11 +248,41 @@ ClingoAccess::startSolving(void)
 
 	if ( Debug )
 	{
-		Log->log_info(LogComponent.c_str(), "Start solving.");
+		Log->log_info(LogComponent.c_str(), "Start async solving.");
 	} //if ( Debug )
+	Solving = true;
 	Control.solve_async([this](const Clingo::Model& model) { return newModel(model); },
 		[this](const Clingo::SolveResult& result) { solvingFinished(result); return; });
+	return true;
+}
+
+/**
+ * @brief Starts the solving process, if it isn't already running, in a blocking manner, that means it does not start
+ *        the computation in an asynchronous way.
+ * @return If the process was started.
+ */
+bool
+ClingoAccess::startSolvingBlocking(void)
+{
+	MutexLocker locker(&ControlMutex);
+	if ( Solving )
+	{
+		return false;
+	} //if ( Solving )
+
+	if ( Debug )
+	{
+		Log->log_info(LogComponent.c_str(), "Start sync solving.");
+	} //if ( Debug )
 	Solving = true;
+	const auto result(Control.solve([this,&locker](const Clingo::Model& model) {
+		locker.unlock();
+		const auto ret = newModel(model);
+		locker.relock();
+		return ret;
+	}));
+	locker.unlock();
+	solvingFinished(result);
 	return true;
 }
 
diff --git a/src/plugins/asp/aspect/clingo_access.h b/src/plugins/asp/aspect/clingo_access.h
index ebeb189..1afabc8 100644
--- a/src/plugins/asp/aspect/clingo_access.h
+++ b/src/plugins/asp/aspect/clingo_access.h
@@ -68,6 +68,7 @@ class ClingoAccess
 
 	bool solving(void) const noexcept;
 	bool startSolving(void);
+	bool startSolvingBlocking(void);
 	bool cancelSolving(void);
 
 	Clingo::SymbolVector modelSymbols(void) const;




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list