Moved deprecated files/folders to temp-folder, FI-stuff removed, cleaned up aspect (file-)names and code (-> coding-style).
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1320 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -1,24 +0,0 @@
|
||||
#include "ExperimentDataQueue.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
// FIXME: This is deprecated stuff. Remove it.
|
||||
|
||||
namespace fi
|
||||
{
|
||||
|
||||
void ExperimentDataQueue::addData(ExperimentData* exp)
|
||||
{
|
||||
assert(exp != 0);
|
||||
m_queue.push_front(exp);
|
||||
}
|
||||
|
||||
ExperimentData* ExperimentDataQueue::getData()
|
||||
{
|
||||
ExperimentData* ret = m_queue.back();
|
||||
m_queue.pop_back();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* \brief A queue for experiment data.
|
||||
*
|
||||
*
|
||||
* \author Martin Hoffmann, Richard Hellwig
|
||||
*
|
||||
*/
|
||||
|
||||
// FIXME: This is deprecated stuff. Remove it.
|
||||
|
||||
#ifndef __EXPERIMENT_DATA_QUEUE_H__
|
||||
#define __EXPERIMENT_DATA_QUEUE_H__
|
||||
|
||||
|
||||
#include <deque>
|
||||
#include "ExperimentData.hpp"
|
||||
|
||||
|
||||
namespace fi{
|
||||
|
||||
/**
|
||||
* \class ExperimentDataQueue
|
||||
* Class which manage ExperimentData in a queue.
|
||||
*/
|
||||
class ExperimentDataQueue
|
||||
{
|
||||
protected:
|
||||
std::deque<ExperimentData*> m_queue;
|
||||
|
||||
public:
|
||||
ExperimentDataQueue() {}
|
||||
~ExperimentDataQueue() {}
|
||||
|
||||
/**
|
||||
* Adds ExperimentData to the queue.
|
||||
* @param exp ExperimentData that is to be added to the queue.
|
||||
*/
|
||||
void addData(ExperimentData* exp);
|
||||
/**
|
||||
* Returns an item from the queue
|
||||
* @return the next element of the queue
|
||||
*/
|
||||
ExperimentData* getData();
|
||||
/**
|
||||
* Returns the number of elements in the queue
|
||||
* @return the size of teh queue
|
||||
*/
|
||||
size_t size() const { return m_queue.size(); };
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif //__EXPERIMENT_DATA_QUEUE_H__
|
||||
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
|
||||
// Author: Adrian Böckenkamp
|
||||
// Date: 15.06.2011
|
||||
|
||||
// FIXME: This is deprecated stuff. Delete it.
|
||||
|
||||
#include "Signal.hpp"
|
||||
|
||||
namespace fi
|
||||
{
|
||||
|
||||
std::auto_ptr<Signal> Signal::m_This;
|
||||
Mutex Signal::m_InstanceMutex;
|
||||
|
||||
|
||||
} // end-of-namespace: fi
|
||||
@ -1,135 +0,0 @@
|
||||
#ifndef __SIGNAL_HPP__
|
||||
#define __SIGNAL_HPP__
|
||||
|
||||
// FIXME: This is deprecated stuff. Delete it.
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#ifndef __puma
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/interprocess/sync/named_semaphore.hpp>
|
||||
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#endif
|
||||
|
||||
namespace fi
|
||||
{
|
||||
|
||||
#ifndef __puma
|
||||
typedef boost::mutex Mutex; // lock/unlock
|
||||
typedef boost::mutex::scoped_lock ScopeLock; // use RAII with lock/unlock mechanism
|
||||
typedef boost::condition_variable ConditionVariable; // wait/notify_one
|
||||
#else
|
||||
typedef int Mutex;
|
||||
typedef int ScopeLock;
|
||||
typedef int ConditionVariable;
|
||||
#endif
|
||||
|
||||
// Simulate a "private" semaphore using boost-mechanisms:
|
||||
class Semaphore
|
||||
{
|
||||
private:
|
||||
Mutex m_Mutex;
|
||||
ConditionVariable m_CondVar;
|
||||
unsigned long m_Value;
|
||||
public:
|
||||
// Create a semaphore object based on a mutex and a condition variable
|
||||
// and initialize it to value "init".
|
||||
Semaphore(unsigned long init = 0) : m_Value(init) { }
|
||||
|
||||
void post()
|
||||
{
|
||||
ScopeLock lock(m_Mutex);
|
||||
++m_Value; // increase semaphore value:
|
||||
#ifndef __puma
|
||||
m_CondVar.notify_one(); // wake up other thread, currently waiting on condition var.
|
||||
#endif
|
||||
}
|
||||
|
||||
void wait()
|
||||
{
|
||||
ScopeLock lock(m_Mutex);
|
||||
#ifndef __puma
|
||||
while(!m_Value) // "wait-if-zero"
|
||||
m_CondVar.wait(lock);
|
||||
#endif
|
||||
--m_Value; // decrease semaphore value
|
||||
}
|
||||
};
|
||||
|
||||
class Signal
|
||||
{
|
||||
private:
|
||||
static Mutex m_InstanceMutex; // used to sync calls to getInst()
|
||||
static std::auto_ptr<Signal> m_This; // the one and only instance
|
||||
|
||||
Semaphore m_semBochs;
|
||||
Semaphore m_semContr;
|
||||
Semaphore m_semSimCtrl;
|
||||
bool m_Locked; // prevent misuse of thread-sync
|
||||
|
||||
// Singleton class (forbid creation, copying and assignment):
|
||||
Signal()
|
||||
: m_semBochs(0), m_semContr(0),
|
||||
m_semSimCtrl(0), m_Locked(false) { }
|
||||
Signal(Signal const& s)
|
||||
: m_semBochs(), m_semContr(),
|
||||
m_semSimCtrl(), m_Locked(false) { } // never called.
|
||||
Signal& operator=(Signal const&) { return *this; } // dito.
|
||||
~Signal() { }
|
||||
friend class std::auto_ptr<Signal>;
|
||||
public:
|
||||
static Signal& getInst()
|
||||
{
|
||||
ScopeLock lock(m_InstanceMutex); // lock/unlock handled by RAII principle
|
||||
if(!m_This.get())
|
||||
m_This.reset(new Signal());
|
||||
return (*m_This);
|
||||
}
|
||||
|
||||
// Called from Experiment-Controller class ("beyond Bochs"):
|
||||
void lockExperiment()
|
||||
{
|
||||
assert(!m_Locked &&
|
||||
"[Signal::lockExperiment]: lockExperiment called twice without calling unlockExperiment() in between.");
|
||||
m_Locked = true;
|
||||
m_semContr.wait(); // suspend experiment process
|
||||
}
|
||||
|
||||
// Called from Experiment-Controller class ("beyond Bochs"):
|
||||
void unlockExperiment()
|
||||
{
|
||||
assert(m_Locked &&
|
||||
"[Signal::unlockExperiment]: unlockExperiment called twice without calling lockExperiment() in between.");
|
||||
m_Locked = false;
|
||||
m_semBochs.post(); // resume experiment (continue bochs simulation)
|
||||
}
|
||||
|
||||
// Called from Advice-Code ("within Bochs") to trigger event occurrence:
|
||||
void signalEvent()
|
||||
{
|
||||
m_semContr.post(); // Signal event (to Experiment-Controller)
|
||||
m_semBochs.wait(); // Wait upon handling to finish
|
||||
}
|
||||
|
||||
// Called from Experiment-Controller to allow simulation start:
|
||||
void startSimulation()
|
||||
{
|
||||
m_semSimCtrl.post();
|
||||
}
|
||||
|
||||
// Called from Bochs, directly after thread creation for Experiment-Controller:
|
||||
// (This ensures that Bochs waits until the experiment has been set up in the
|
||||
// Experiment-Controller.)
|
||||
void waitForStartup()
|
||||
{
|
||||
m_semSimCtrl.wait();
|
||||
}
|
||||
};
|
||||
|
||||
} // end-of-namespace: fi
|
||||
|
||||
#endif /* __SIGNAL_HPP__ */
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
#include "SynchronizedExperimentDataQueue.hpp"
|
||||
|
||||
// FIXME: This file is not used. Delete it either.
|
||||
|
||||
namespace fi {
|
||||
|
||||
void SynchronizedExperimentDataQueue::addData(ExperimentData* exp){
|
||||
//
|
||||
m_sema_full.wait();
|
||||
ExperimentDataQueue::addData(exp);
|
||||
m_sema_empty.post();
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
ExperimentData* SynchronizedExperimentDataQueue::getData(){
|
||||
//
|
||||
m_sema_empty.wait();
|
||||
return ExperimentDataQueue::getData();
|
||||
m_sema_full.post();
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* \brief A queue for experiment data.
|
||||
*
|
||||
*
|
||||
* \author Martin Hoffmann, Richard Hellwig
|
||||
*
|
||||
*/
|
||||
|
||||
// FIXME: This file is not used. Delete it.
|
||||
|
||||
#ifndef __SYNC_EXPERIMENT_DATA_QUEUE_H__
|
||||
#define __SYNC_EXPERIMENT_DATA_QUEUE_H__
|
||||
|
||||
#include "ExperimentDataQueue.hpp"
|
||||
#include "Signal.hpp"
|
||||
|
||||
namespace fi{
|
||||
|
||||
/**
|
||||
* \class SynchronizedExperimentDataQueue
|
||||
* Class which manage ExperimentData in a queue.
|
||||
* Thread safe using semphores.
|
||||
*/
|
||||
class SynchronizedExperimentDataQueue : public ExperimentDataQueue
|
||||
{
|
||||
private:
|
||||
/// There are maxSize elements in at a time
|
||||
/// Or do we allow a really possibly huge queue?
|
||||
Semaphore m_sema_full;
|
||||
Semaphore m_sema_empty;
|
||||
|
||||
public:
|
||||
SynchronizedExperimentDataQueue(int maxSize = 1024) : m_sema_full(maxSize), m_sema_empty(0) {}
|
||||
~SynchronizedExperimentDataQueue() {}
|
||||
|
||||
/**
|
||||
* Adds ExperimentData to the queue.
|
||||
* @param exp ExperimentData that is to be added to the queue.
|
||||
*/
|
||||
void addData(ExperimentData* exp);
|
||||
/**
|
||||
* Returns an item from the queue
|
||||
* @return the next element of the queue
|
||||
*/
|
||||
ExperimentData* getData();
|
||||
/**
|
||||
* Returns the number of elements in the queue
|
||||
* @return the size of the queue
|
||||
*/
|
||||
size_t size() const { return m_queue.size(); };
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif //__EXPERIMENT_DATA_QUEUE_H__
|
||||
|
||||
|
||||
Reference in New Issue
Block a user