Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Core/Python/PythonInterpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ void PythonInterpreter::set_python_argv(const std::vector<std::string>& argv)

void PythonInterpreter::initialize(bool needProgramName, const std::string& commandLine, const boost::filesystem::path& libPath)
{
if (this->private_->initialized_)
return;

const auto argv = argvFromFullString(commandLine);

if (needProgramName)
Expand Down
17 changes: 14 additions & 3 deletions src/Dataflow/State/SimpleMapModuleState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ SimpleMapModuleState::SimpleMapModuleState(SimpleMapModuleState&& rhs)

SimpleMapModuleState::SimpleMapModuleState(const SimpleMapModuleState& rhs)
: stateMap_(rhs.stateMap_),
transientStateMap_(rhs.transientStateMap_), /// @todo: I think this is wrong, transient shouldn't be copied
name_(rhs.name_)
{
std::lock_guard<std::mutex> lock(rhs.transientMutex_);
transientStateMap_ = rhs.transientStateMap_; /// @todo: I think this is wrong, transient shouldn't be copied
//std::cout << "SMMS copy ctor " << name_ << std::endl;
}

Expand All @@ -66,7 +67,10 @@ SimpleMapModuleState& SimpleMapModuleState::operator=(const SimpleMapModuleState
if (&rhs != this)
{
stateMap_ = rhs.stateMap_;
transientStateMap_ = rhs.transientStateMap_; /// @todo: I think this is wrong, transient shouldn't be copied
{
std::lock_guard<std::mutex> lock(rhs.transientMutex_);
transientStateMap_ = rhs.transientStateMap_; /// @todo: I think this is wrong, transient shouldn't be copied
}
name_ = rhs.name_;
//std::cout << "SMMS copy assign " << name_<< std::endl;
/// @todo??
Expand Down Expand Up @@ -151,6 +155,7 @@ ModuleStateInterface::Keys SimpleMapModuleState::getKeys() const

void SimpleMapModuleState::print() const
{
std::lock_guard<std::mutex> lock(transientMutex_);
std::cout << "Printing transient map: " << this << " name: " << name_ << std::endl;
for (auto q = transientStateMap_.begin(); q != transientStateMap_.end(); ++q)
{
Expand All @@ -161,16 +166,22 @@ void SimpleMapModuleState::print() const

SimpleMapModuleState::TransientValueOption SimpleMapModuleState::getTransientValue(const Name& name) const
{
std::lock_guard<std::mutex> lock(transientMutex_);
//print();
auto i = transientStateMap_.find(name.name());
return i != transientStateMap_.end() && !i->second.empty() ? std::optional(i->second) : TransientValueOption();
}

void SimpleMapModuleState::setTransientValue(const Name& name, const TransientValue& value, bool fireSignal)
{
transientStateMap_[name.name()] = value;
{
std::lock_guard<std::mutex> lock(transientMutex_);
transientStateMap_[name.name()] = value;
}
//print();

// Fire signals outside the lock to avoid re-entrancy through signal handlers
// that call back into get/setTransientValue.
if (fireSignal)
{
fireTransientStateChangeSignal();
Expand Down
2 changes: 2 additions & 0 deletions src/Dataflow/State/SimpleMapModuleState.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define DATAFLOW_STATE_SIMPLEMAPMODULESTATE_H

#include <map>
#include <mutex>
#include <Dataflow/Network/ModuleStateInterface.h>
#include <Dataflow/State/share.h>

Expand Down Expand Up @@ -64,6 +65,7 @@ namespace State {
StateMap stateMap_;
typedef std::map<std::string, TransientValue> TransientStateMap;
TransientStateMap transientStateMap_;
mutable std::mutex transientMutex_;
state_changed_sig_t stateChangedSignal_;
provenance_state_changed_sig_t provenanceStateChangedSignal_;
std::map<Name, state_changed_sig_t> specificStateChangeSignalMap_;
Expand Down
Loading