| 24 | } |
| 25 | |
| 26 | void EmbeddedPython::shutdown() |
| 27 | { |
| 28 | if ( !isAvailable() ) |
| 29 | return; |
| 30 | |
| 31 | EmbeddedPython &self = instance_(); |
| 32 | self.shutdownCalled_ = true; |
| 33 | |
| 34 | if ( !self.interpreterThread_.joinable() ) |
| 35 | return; // Nothing to do. |
| 36 | |
| 37 | { // Tell the thread to stop. |
| 38 | spdlog::debug( "EmbeddedPython: shutdown, waiting for lock" ); |
| 39 | std::unique_lock guard( self.cvMutex_ ); |
| 40 | self.stopInterpreterThread_ = true; |
| 41 | self.cv_.notify_all(); |
| 42 | } |
| 43 | spdlog::debug( "EmbeddedPython: shutdown, join python thread" ); |
| 44 | self.interpreterThread_.join(); |
| 45 | } |
| 46 | |
| 47 | bool EmbeddedPython::runString( std::string pythonString, std::function<void( bool success )> onDoneAsync ) |
| 48 | { |