Skip to content

Commit

Permalink
Removing life-cycle consistency checks from AutoPacket.
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielHare committed Jul 30, 2014
1 parent a531813 commit d513f3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 65 deletions.
34 changes: 0 additions & 34 deletions autowiring/AutoPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ class AutoPacket:
AutoPacket(const AutoPacket& rhs) = delete;
AutoPacket(AutoPacketFactory& factory);

//DEBUG BEGIN: Verify adherence to life plans
//QUESTION: Does this need to be promoted to a condition
//for calling Finalize in the destructor?
int debug_lifecycle;
static const int lifecycle_construct = 0;
static const int lifecycle_inpool = 1;
static const int lifecycle_issued = 2;
static const int lifecycle_destruct = 3;
//DEBUG END

public:
~AutoPacket(void);

Expand Down Expand Up @@ -247,12 +237,6 @@ class AutoPacket:
/// </remarks>
template<class T>
AutoCheckout<T> Checkout(std::shared_ptr<T> ptr) {
if (!(debug_lifecycle == lifecycle_issued)) {
std::stringstream ss;
ss << "Checkout called in lifecycle: " << debug_lifecycle;
//throw std::runtime_error(ss.str());
}

// This allows us to install correct entries for decorated input requests
typedef typename subscriber_traits<T>::type type;

Expand Down Expand Up @@ -306,12 +290,6 @@ class AutoPacket:
/// </remarks>
template<class T>
void Unsatisfiable(void) {
if (!(debug_lifecycle == lifecycle_issued)) {
std::stringstream ss;
ss << "Unsatisfiable called in lifecycle: " << debug_lifecycle;
//throw std::runtime_error(ss.str());
}

{
// Insert a null entry at this location:
std::lock_guard<std::mutex> lk(m_lock);
Expand Down Expand Up @@ -350,12 +328,6 @@ class AutoPacket:
/// </remarks>
template<class T>
const T& Decorate(std::shared_ptr<T> t) {
if (!(debug_lifecycle == lifecycle_issued)) {
std::stringstream ss;
ss << "Decorate called in lifecycle: " << debug_lifecycle;
//throw std::runtime_error(ss.str());
}

Checkout<T>(t).Ready();
return *t;
}
Expand All @@ -374,12 +346,6 @@ class AutoPacket:
/// </remarks>
template<class... Ts>
void DecorateImmediate(const Ts&... immeds) {
if (!(debug_lifecycle == lifecycle_issued)) {
std::stringstream ss;
ss << "DecorateImmediate called in lifecycle: " << debug_lifecycle;
//throw std::runtime_error(ss.str());
}

// These are the things we're going to be working with while we perform immediate decoration:
static const std::type_info* sc_typeInfo [] = {&typeid(Ts)...};
const void* pvImmeds[] = {&immeds...};
Expand Down
33 changes: 2 additions & 31 deletions src/autowiring/AutoPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

#include <iostream>

AutoPacket::AutoPacket(AutoPacketFactory& factory) : debug_lifecycle(0)
{
AutoPacket::AutoPacket(AutoPacketFactory& factory) {
// Traverse all contexts, adding their packet subscriber vectors one at a time:
for(const auto& curContext : ContextEnumerator(factory.GetContext())) {
AutowiredFast<AutoPacketFactory> curFactory(curContext);
Expand Down Expand Up @@ -59,15 +58,7 @@ AutoPacket::AutoPacket(AutoPacketFactory& factory) : debug_lifecycle(0)

// This must appear in .cpp in order to avoid compilation failure due to:
// "Arithmetic on a point to an incomplete type 'SatCounter'"
AutoPacket::~AutoPacket() {
if (debug_lifecycle == lifecycle_issued) {
std::cout << "Destruct before Finalize!" << std::endl;
}
if (debug_lifecycle == lifecycle_destruct) {
throw std::runtime_error("Destruct called Twice!");
}
debug_lifecycle = 3;
}
AutoPacket::~AutoPacket() {}

ObjectPool<AutoPacket> AutoPacket::CreateObjectPool(AutoPacketFactory& factory) {
return ObjectPool<AutoPacket>(
Expand Down Expand Up @@ -153,13 +144,6 @@ void AutoPacket::PulseSatisfaction(DecorationDisposition* pTypeSubs[], size_t nI
}

void AutoPacket::Reset(void) {
if (!(debug_lifecycle == lifecycle_construct || debug_lifecycle == lifecycle_issued)) {
std::stringstream ss;
ss << "Reset called in lifecycle: " << debug_lifecycle;
//throw std::runtime_error(ss.str());
}
debug_lifecycle = lifecycle_inpool;

// Initialize all counters:
std::lock_guard<std::mutex> lk(m_lock);
for(auto& satCounter : m_satCounters)
Expand All @@ -171,13 +155,6 @@ void AutoPacket::Reset(void) {
}

void AutoPacket::Initialize(void) {
if (!(debug_lifecycle == lifecycle_inpool)) {
std::stringstream ss;
ss << "Initialize called in lifecycle: " << debug_lifecycle;
//throw std::runtime_error(ss.str());
}
debug_lifecycle = lifecycle_issued;

// Find all subscribers with no required or optional arguments:
std::list<SatCounter*> callCounters;
for (auto& satCounter : m_satCounters)
Expand All @@ -194,12 +171,6 @@ void AutoPacket::Initialize(void) {
}

void AutoPacket::Finalize(void) {
if (!(debug_lifecycle == lifecycle_issued)) {
std::stringstream ss;
ss << "Finalize called in lifecycle: " << debug_lifecycle;
//throw std::runtime_error(ss.str());
}

// Queue calls to ensure that calls to Decorate inside of AutoFilter methods
// will NOT effect the resolution of optional arguments.
std::list<SatCounter*> callQueue;
Expand Down

0 comments on commit d513f3c

Please sign in to comment.