Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for auto_prev #1052

Merged
merged 1 commit into from Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion Doxyfile
Expand Up @@ -691,7 +691,6 @@ FILE_PATTERNS = "at_exit.h" \
"auto_arg.h" \
"auto_in.h" \
"auto_out.h" \
"auto_prev.h" \
"AutoConfig.h" \
"AutoNetServer.h" \
"AutoPacket.h" \
Expand Down
3 changes: 0 additions & 3 deletions devguide/Files.dox
Expand Up @@ -11,8 +11,6 @@

/// \file auto_out.h

/// \file auto_prev.h

/// \file AutowiringDebug.h

/// \file AutoConfig.h
Expand Down Expand Up @@ -71,4 +69,3 @@
/// \file MicroBolt.h

/// \file Object.h

1 change: 0 additions & 1 deletion publicDoxyfile.conf
Expand Up @@ -782,7 +782,6 @@ FILE_PATTERNS = "at_exit.h" \
"auto_arg.h" \
"auto_in.h" \
"auto_out.h" \
"auto_prev.h" \
"AutoConfig.h" \
"AutoNetServer.h" \
"AutoPacket.h" \
Expand Down
10 changes: 3 additions & 7 deletions src/autowiring/AutoFilterArgument.h
Expand Up @@ -19,16 +19,14 @@ struct AutoFilterArgument {
bool is_rvalue,
bool is_shared,
bool is_multi,
auto_id id,
int tshift
auto_id id
) :
is_input(is_input),
is_output(is_output),
is_rvalue(is_rvalue),
is_shared(is_shared),
is_multi(is_multi),
id(id),
tshift(tshift)
id(id)
{}

public:
Expand All @@ -38,7 +36,6 @@ struct AutoFilterArgument {
const bool is_shared = false;
const bool is_multi = false;
const auto_id id = auto_id_t<void>{};
const int tshift = 0;

explicit operator bool(void) const {
return static_cast<bool>(id);
Expand All @@ -56,8 +53,7 @@ struct AutoFilterArgumentT:
auto_arg<T>::is_rvalue,
auto_arg<T>::is_shared,
auto_arg<T>::is_multi,
typename auto_arg<T>::id_type(),
auto_arg<T>::tshift
typename auto_arg<T>::id_type()
)
{}
};
Expand Down
79 changes: 7 additions & 72 deletions src/autowiring/AutoPacket.cpp
Expand Up @@ -36,29 +36,9 @@ AutoPacket::~AutoPacket(void) {
)
);

// Mark decorations of successor packets that use decorations
// originating from this packet as unsatisfiable
for (auto& pair : m_decoration_map)
if (!pair.first.tshift && pair.second.m_state != DispositionState::Complete)
MarkSuccessorsUnsatisfiable(DecorationKey(pair.first.id, 0));

// Needed for the AutoPacketGraph
NotifyTeardownListeners();

// Create vector of all successor packets that will be destroyed
// This prevents recursive AutoPacket destructor calls
std::vector<std::shared_ptr<AutoPacket>> packets;

// Recurse through unique successors, storing them in our vector
for (AutoPacket* current = this; current->m_successor.unique();) {
packets.push_back(current->m_successor);

// Reset and continue to next successor
AutoPacket* prev_current = current;
current = current->m_successor.get();
prev_current->m_successor.reset();
}

// Safe linked list unwind
for (auto cur = m_firstCounter; cur;) {
auto next = cur->flink;
Expand Down Expand Up @@ -87,13 +67,9 @@ DecorationDisposition& AutoPacket::DecorateImmediateUnsafe(const DecorationKey&

void AutoPacket::AddSatCounterUnsafe(SatCounter& satCounter) {
for(auto pCur = satCounter.GetAutoFilterArguments(); *pCur; pCur++) {
DecorationKey key(pCur->id, pCur->tshift);
DecorationKey key(pCur->id);
DecorationDisposition& entry = m_decoration_map[key];

// Make sure decorations exist for timeshifts less that key's timeshift
for (int tshift = 0; tshift < key.tshift; ++tshift)
m_decoration_map[DecorationKey(key.id, tshift)];

// Decide what to do with this entry:
if (pCur->is_input) {
if (entry.m_publishers.size() > 1 && !pCur->is_multi) {
Expand Down Expand Up @@ -181,7 +157,7 @@ void AutoPacket::DetectCycle(SatCounter& satCounter, std::unordered_set<SatCount
for(auto pCur = satCounter.GetAutoFilterArguments(); *pCur; pCur++) {
if (!pCur->is_output) continue;

DecorationKey key(pCur->id, pCur->tshift);
DecorationKey key(pCur->id);
DecorationDisposition& entry = m_decoration_map[key];
for (auto& subscriber : entry.m_subscribers) {
auto ptr = subscriber.satCounter;
Expand All @@ -201,7 +177,7 @@ void AutoPacket::DetectCycle(SatCounter& satCounter, std::unordered_set<SatCount

void AutoPacket::RemoveSatCounterUnsafe(const SatCounter& satCounter) {
for (auto pCur = satCounter.GetAutoFilterArguments(); *pCur; pCur++) {
DecorationKey key(pCur->id, pCur->tshift);
DecorationKey key(pCur->id);
DecorationDisposition& entry = m_decoration_map[key];

if (pCur->is_rvalue) {
Expand Down Expand Up @@ -253,22 +229,6 @@ void AutoPacket::MarkUnsatisfiable(const DecorationKey& key) {
UpdateSatisfactionUnsafe(std::move(lk), entry);
}

void AutoPacket::MarkSuccessorsUnsatisfiable(DecorationKey key) {
std::lock_guard<std::mutex> lk(m_lock);

// Update key and successor
key.tshift++;
auto successor = SuccessorUnsafe();

while (m_decoration_map.count(key)) {
successor->MarkUnsatisfiable(key);

// Update key and successor
key.tshift++;
successor = successor->Successor();
}
}

void AutoPacket::UpdateSatisfactionUnsafe(std::unique_lock<std::mutex> lk, const DecorationDisposition& disposition) {
// Update satisfaction inside of lock
if (disposition.m_state != DispositionState::Complete)
Expand Down Expand Up @@ -388,7 +348,7 @@ void AutoPacket::UpdateSatisfactionUnsafe(std::unique_lock<std::mutex> lk, const
// Mark all unsatisfiable output types
for (auto unsatOutputArg : unsatOutputArgs) {
// One more producer run, even though we couldn't attach any new decorations
auto& disposition = m_decoration_map[DecorationKey{unsatOutputArg->id, 0}];
auto& disposition = m_decoration_map[DecorationKey{unsatOutputArg->id}];
if(disposition.IncProducerCount())
// Recurse on this entry
UpdateSatisfactionUnsafe(std::unique_lock<std::mutex>{m_lock}, disposition);
Expand Down Expand Up @@ -491,19 +451,8 @@ void AutoPacket::DecorateNoPriors(const AnySharedPointer& ptr, DecorationKey key
void AutoPacket::Decorate(const AnySharedPointer& ptr, DecorationKey key) {
auto cur = shared_from_this();

do {
// Update satisfaction set on this entry
cur->DecorateNoPriors(ptr, key);

// Obtain the successor
cur = cur->Successor();
key.tshift++;
} while (
// If there are any filters on _this_ packet that desire to know the prior packet, then
// we must proactively preserve the value of this decoration for our successor.
(std::lock_guard<std::mutex>)m_lock,
m_decoration_map.count(key)
);
// Update satisfaction set on this entry
cur->DecorateNoPriors(ptr, key);
}

void AutoPacket::RemoveDecoration(DecorationKey key) {
Expand Down Expand Up @@ -577,7 +526,7 @@ AutoPacket::t_decorationMap AutoPacket::GetDecorations(void) const

bool AutoPacket::IsUnsatisfiable(const auto_id& id) const
{
const DecorationDisposition* pDisposition = GetDisposition(DecorationKey{ id, 0 });
const DecorationDisposition* pDisposition = GetDisposition(DecorationKey{ id });
if (!pDisposition)
// We have never heard of this type
return false;
Expand Down Expand Up @@ -647,20 +596,6 @@ void AutoPacket::RemoveRecipient(const SatCounter& recipient) {
RemoveSatCounterUnsafe(recipient);
}

std::shared_ptr<AutoPacket> AutoPacket::Successor(void) {
std::lock_guard<std::mutex> lk(m_lock);
return SuccessorUnsafe();
}

std::shared_ptr<AutoPacket> AutoPacket::SuccessorUnsafe(void) {
// If successor doesn't already exists, create it
if (!m_successor){
m_successor = m_parentFactory->ConstructPacket();
}

return m_successor;
}

AutoPacket* AutoPacket::SetCurrent(AutoPacket* apkt) {
AutoPacket* prior = autoCurrentPacket.get();
if(apkt)
Expand Down