knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::ReasonerRunner Class Reference

#include <GoalDrivenReasoner.h>

Inheritance diagram for knowrob::ReasonerRunner:
Collaboration diagram for knowrob::ReasonerRunner:

Public Member Functions

 ReasonerRunner ()=default
 
void run () override
 
 ReasonerRunner ()=default
 
void run () override
 
- Public Member Functions inherited from knowrob::ThreadPool::Runner
 Runner ()
 
virtual ~Runner ()
 
 Runner (const Runner &)=delete
 
void join ()
 
void stop (bool wait)
 
bool hasStopRequest () const
 
bool isTerminated () const
 
 Runner ()
 
virtual ~Runner ()
 
 Runner (const Runner &)=delete
 
void join ()
 
void stop (bool wait)
 
bool hasStopRequest () const
 
bool isTerminated () const
 

Public Attributes

std::shared_ptr< GoalDrivenReasonerreasoner
 
std::shared_ptr< Goalquery
 

Additional Inherited Members

- Protected Member Functions inherited from knowrob::ThreadPool::Runner
void runInternal ()
 
void setExceptionHandler (ExceptionHandler exceptionHandler)
 
void runInternal ()
 
void setExceptionHandler (ExceptionHandler exceptionHandler)
 
- Protected Attributes inherited from knowrob::ThreadPool::Runner
std::atomic< bool > isTerminated_
 
std::atomic< bool > isRunning_
 
std::atomic< bool > hasStopRequest_
 
std::mutex mutex_
 
std::condition_variable finishedCV_
 
ExceptionHandler exceptionHandler_
 

Detailed Description

A runner that can be used to evaluate a query in a thread pool.

Definition at line 134 of file GoalDrivenReasoner.h.

Constructor & Destructor Documentation

◆ ReasonerRunner() [1/2]

knowrob::ReasonerRunner::ReasonerRunner ( )
default

◆ ReasonerRunner() [2/2]

knowrob::ReasonerRunner::ReasonerRunner ( )
default

Member Function Documentation

◆ run() [1/2]

void ReasonerRunner::run ( )
overridevirtual

Run the computation in a worker thread.

Implements knowrob::ThreadPool::Runner.

Definition at line 59 of file GoalDrivenReasoner.cpp.

59  {
60  if (reasoner->reasonerLanguage() == PluginLanguage::PYTHON) {
61  // If the reasoner uses Python code, then we must make sure that the GIL is acquired
62  // in the current thread before calling the reasoner.
63  // Note that due to Python's GIL, only one thread can execute Python code at a time
64  // but Python should do switching between threads automatically.
65  py::gil_lock acquire;
66  run_();
67  } else {
68  run_();
69  }
70 }
std::shared_ptr< GoalDrivenReasoner > reasoner

◆ run() [2/2]

void knowrob::ReasonerRunner::run ( )
overridevirtual

Run the computation in a worker thread.

Implements knowrob::ThreadPool::Runner.

Member Data Documentation

◆ query

std::shared_ptr< Goal > knowrob::ReasonerRunner::query

Definition at line 137 of file GoalDrivenReasoner.h.

◆ reasoner

std::shared_ptr< GoalDrivenReasoner > knowrob::ReasonerRunner::reasoner

Definition at line 136 of file GoalDrivenReasoner.h.


The documentation for this class was generated from the following files: