World Ocean Simulation System (WOSS) library
|
Multi-threaded extension of WossManagerResDb. More...
#include <woss-manager.h>
Classes | |
struct | ThreadCondSignal |
struct | ThreadParam |
struct | ThreadQuery |
Public Member Functions | |
WossManagerResDbMT () | |
virtual Pressure * | getWossPressure (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value) |
virtual Pressure * | getWossPressure (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, double time_value) |
virtual TimeArr * | getWossTimeArr (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value) |
virtual TimeArr * | getWossTimeArr (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, double time_value) |
virtual PressureVector | getWossPressure (const CoordZPairVect &coordinates, double start_frequency, double end_frequency, const Time &time_value) |
virtual PressureVector | getWossPressure (const CoordZPairVect &coordinates, double start_frequency, double end_frequency, double time_value) |
virtual TimeArrVector | getWossTimeArr (const CoordZPairVect &coordinates, double start_frequency, double end_frequency, const Time &time_value) |
virtual TimeArrVector | getWossTimeArr (const CoordZPairVect &coordinates, double start_frequency, double end_frequency, double time_value) |
void | setConcurrentThreads (int number) |
int | getConcurrentThreads () |
Public Member Functions inherited from woss::WossManagerResDb | |
WossManagerResDb & | setWossDbManager (const WossDbManager *const ptr) |
Public Member Functions inherited from woss::WossManager | |
WossManager () | |
virtual const Woss & | getActiveWoss (const CoordZ &tx, const CoordZ &rx, double start_frequency, double end_frequency) const |
virtual WossManager & | eraseActiveWoss (const CoordZ &tx, const CoordZ &rx, double start_frequency, double end_frequency)=0 |
virtual bool | reset ()=0 |
virtual bool | timeEvolve (const Time &time_value)=0 |
WossManager & | setWossCreator (const WossCreator *const ptr) |
void | setTimeEvolutionActiveFlag (bool flag) |
void | setDebugFlag (bool flag) |
const WossCreator *const | getWossCreator () |
bool | getTimeEvolutionActiveFlag () |
bool | getDebugFlag () |
Protected Types | |
typedef ::std::pair< int, ThreadParam > | ThreadParamIndex |
typedef ::std::map< Woss *, ThreadCondSignal * > | ActiveWoss |
typedef ActiveWoss::iterator | AWIter |
typedef ActiveWoss::reverse_iterator | AWRIter |
typedef ActiveWoss::const_iterator | AWCIter |
typedef ActiveWoss::const_reverse_iterator | AWCRIter |
Protected Member Functions | |
void | checkConcurrentThreads () |
void | initThreadVars () |
ThreadParamIndex | popThreadParamIndex () |
void | insertThreadReplyTimeArr (int index, woss::TimeArr *time_arr) |
void | insertThreadReplyPressure (int index, woss::Pressure *pressure) |
Protected Member Functions inherited from woss::WossManagerResDb | |
TimeArr * | dbGetTimeArr (const CoordZ &tx, const CoordZ &rx, double frequency, const Time &time_value) const |
void | dbInsertTimeArr (const CoordZ &tx, const CoordZ &rx, double frequency, const Time &time_value, const TimeArr &channel) const |
Pressure * | dbGetPressure (const CoordZ &tx, const CoordZ &rx, double frequency, const Time &time_value) const |
void | dbInsertPressure (const CoordZ &tx, const CoordZ &rx, double frequency, const Time &time_value, const Pressure &press) const |
Protected Member Functions inherited from woss::WossManager | |
virtual Woss *const | getWoss (const CoordZ &tx, const CoordZ &rx, double start_frequency, double end_frequency)=0 |
Protected Attributes | |
int | max_thread_number |
int | total_queries |
int | concurrent_threads |
volatile int | total_thread_created |
volatile int | total_thread_ended |
pthread_t | thread_controller |
pthread_t | thread_arr [MAX_TOTAL_PTHREAD] |
pthread_spinlock_t | mutex |
pthread_spinlock_t | request_mutex |
ThreadQuery | thread_query |
TimeArrVector | thread_time_arr_reply |
PressureVector | thread_pressure_reply |
ActiveWoss | active_woss |
Protected Attributes inherited from woss::WossManagerResDb | |
const WossDbManager * | woss_db_manager |
Protected Attributes inherited from woss::WossManager | |
const WossCreator * | woss_creator |
bool | debug |
bool | is_time_evolution_active |
Friends | |
void * | WMSMTcreateThreadTimeArr (void *ptr) |
void * | WMSMTcreateThreadPressure (void *ptr) |
Additional Inherited Members | |
Static Protected Attributes inherited from woss::WossManager | |
static const Time | NO_EVOLUTION_TIME = Time(1,1,1901,1,1,1) |
Multi-threaded extension of WossManagerResDb.
WossManagerResDbMT is a multi-threaded extension of WossManagerResDb. It uses the pthread library. This class is optimized for multi-processor cpu.Don't use it if a multi-processor cpu is not installed. Please notice that simulation will suffer an heavy time penalty if a result db is used and Woss objects are not run. This is due to the thread creation and synchronization overhead. Therefore no multi-thread should be used when reading already computed channel simulator data.
|
protected |
Type used by an active query thread
WossManagerResDbMT::WossManagerResDbMT | ( | ) |
WossManagerResDbMT default constructor
References checkConcurrentThreads(), max_thread_number, mutex, and request_mutex.
|
protected |
Sets concurrent_threads valid range
References concurrent_threads, woss::WossManager::debug, and max_thread_number.
Referenced by setConcurrentThreads(), and WossManagerResDbMT().
|
inline |
Gets the number of concurrent threads
References concurrent_threads.
|
virtual |
Returns a valid Pressure for given parameters
tx | const reference to a valid CoordZ object ( transmitter ) |
rx | const reference to a valid CoordZ object ( receiver ) |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | const reference to a valid Time object |
Reimplemented from woss::WossManagerResDb.
References active_woss, woss::TimeArr::clear(), concurrent_threads, woss::Pressure::create(), woss::TimeArr::create(), woss::WossManagerResDb::dbGetPressure(), woss::WossManagerResDb::dbInsertPressure(), woss::WossManager::debug, woss::Woss::freq_lower_bound(), woss::Woss::getAvgPressure(), woss::CoordZ::getCartDistance(), woss::CoordZ::getDepth(), woss::WossCreator::getFrequencyStep(), woss::WossManager::getWoss(), woss::WossManagerResDb::getWossPressure(), woss::Singleton< T >::instance(), woss::Woss::isRunning(), woss::Pressure::isValid(), woss::TimeArr::isValid(), request_mutex, woss::Woss::run(), woss::Woss::timeEvolve(), and woss::WossManager::woss_creator.
Referenced by getWossPressure().
|
virtual |
Returns a valid Pressure for given parameters
tx | const reference to a valid CoordZ object ( transmitter ) |
rx | const reference to a valid CoordZ object ( receiver ) |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | number of seconds after start time |
Reimplemented from woss::WossManager.
References woss::WossManager::debug, woss::CoordZ::getCartDistance(), woss::WossCreator::getSimTime(), getWossPressure(), woss::Singleton< T >::instance(), woss::Time::isValid(), request_mutex, and woss::WossManager::woss_creator.
|
virtual |
Returns a valid vector of Pressure* for given parameters
coordinates | const reference to a valid CoordZPairVect |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | const reference to a valid Time object |
Reimplemented from woss::WossManager.
References concurrent_threads, woss::WossManager::getWossPressure(), initThreadVars(), thread_arr, thread_pressure_reply, thread_query, total_queries, total_thread_created, total_thread_ended, and WMSMTcreateThreadPressure.
|
virtual |
Returns a valid vector of Pressure* for given parameters
coordinates | const reference to a valid CoordZPairVect |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | number of seconds after start time |
Reimplemented from woss::WossManager.
References concurrent_threads, woss::WossManager::getWossPressure(), initThreadVars(), thread_arr, thread_pressure_reply, thread_query, total_queries, total_thread_created, total_thread_ended, and WMSMTcreateThreadPressure.
|
virtual |
Returns a valid TimeArr for given parameters
tx | const reference to a valid CoordZ object ( transmitter ) |
rx | const reference to a valid CoordZ object ( receiver ) |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | const reference to a valid Time object |
Reimplemented from woss::WossManagerResDb.
References active_woss, woss::TimeArr::clear(), concurrent_threads, woss::TimeArr::createImpulse(), woss::WossManagerResDb::dbGetTimeArr(), woss::WossManagerResDb::dbInsertTimeArr(), woss::WossManager::debug, woss::Woss::freq_lower_bound(), woss::CoordZ::getCartDistance(), woss::CoordZ::getDepth(), woss::WossCreator::getFrequencyStep(), woss::Coord::getGreatCircleDistance(), woss::Woss::getTimeArr(), woss::WossManager::getWoss(), woss::WossManagerResDb::getWossTimeArr(), woss::Singleton< T >::instance(), woss::Woss::isRunning(), woss::TimeArr::isValid(), request_mutex, woss::Woss::run(), woss::Woss::timeEvolve(), and woss::WossManager::woss_creator.
Referenced by getWossTimeArr().
|
virtual |
Returns a valid TimeArr for given parameters
tx | const reference to a valid CoordZ object ( transmitter ) |
rx | const reference to a valid CoordZ object ( receiver ) |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | number of seconds after start time |
Reimplemented from woss::WossManager.
References woss::TimeArr::createImpulse(), woss::WossManager::debug, woss::CoordZ::getCartDistance(), woss::WossCreator::getSimTime(), getWossTimeArr(), woss::Singleton< T >::instance(), woss::Time::isValid(), request_mutex, and woss::WossManager::woss_creator.
|
virtual |
Returns a valid vector of TimeArr* for given parameters
coordinates | const reference to a valid CoordZPairVect |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | const reference to a valid Time object |
Reimplemented from woss::WossManager.
References concurrent_threads, woss::WossManager::getWossTimeArr(), initThreadVars(), thread_arr, thread_query, thread_time_arr_reply, total_queries, total_thread_created, total_thread_ended, and WMSMTcreateThreadTimeArr.
|
virtual |
Returns a valid vector of TimeArr* for given parameters
coordinates | const reference to a valid CoordZPairVect |
start_freq | start frequency [Hz] |
end_freq | end frequency [Hz] |
time_value | number of seconds after start time |
Reimplemented from woss::WossManager.
References concurrent_threads, woss::WossManager::getWossTimeArr(), initThreadVars(), thread_arr, thread_query, thread_time_arr_reply, total_queries, total_thread_created, total_thread_ended, and WMSMTcreateThreadTimeArr.
|
protected |
Initializes variable for current query round
References concurrent_threads, woss::WossManager::debug, thread_query, total_queries, total_thread_created, and total_thread_ended.
Referenced by getWossPressure(), getWossPressure(), getWossTimeArr(), and getWossTimeArr().
|
protected |
Insert the given Pressure pointer in the PressureVector reply at given index
index | vector index |
pressure | pointer to a heap-created Pressure |
References mutex, and thread_pressure_reply.
Referenced by woss::WMSMTcreateThreadPressure().
|
protected |
Insert the given TimeArr pointer in the TimeArrVector reply at given index
index | vector index |
time_arr | pointer to a heap-created TimeArr |
References mutex, and thread_time_arr_reply.
Referenced by woss::WMSMTcreateThreadTimeArr().
|
protected |
Returns a valid ThreadParamIndex for a requesting thread
References woss::WossManager::debug, mutex, and thread_query.
Referenced by woss::WMSMTcreateThreadPressure(), and woss::WMSMTcreateThreadTimeArr().
|
inline |
Sets the number of concurrent threads. If number < 0 multi-threading is disabled. If number = 0 the thread number is automatically handled.
number | number of concurrent threads |
References checkConcurrentThreads(), and concurrent_threads.
|
friend |
Function used for Pressure thread creation
ptr | void pointer |
Referenced by getWossPressure(), and getWossPressure().
|
friend |
Function used for TimeArr thread creation
ptr | void pointer |
Referenced by getWossTimeArr(), and getWossTimeArr().
|
protected |
Set of current active Woss objects
Referenced by getWossPressure(), and getWossTimeArr().
|
protected |
Max number of concurrent threads
Referenced by checkConcurrentThreads(), getConcurrentThreads(), getWossPressure(), getWossPressure(), getWossPressure(), getWossTimeArr(), getWossTimeArr(), getWossTimeArr(), initThreadVars(), and setConcurrentThreads().
|
protected |
Max number of created threads
Referenced by checkConcurrentThreads(), and WossManagerResDbMT().
|
protected |
Master spinlock
Referenced by insertThreadReplyPressure(), insertThreadReplyTimeArr(), popThreadParamIndex(), and WossManagerResDbMT().
|
protected |
Secondary spinlock
Referenced by getWossPressure(), getWossPressure(), getWossTimeArr(), getWossTimeArr(), and WossManagerResDbMT().
|
protected |
Array of pthread ids associated to the created query threads
Referenced by getWossPressure(), getWossPressure(), getWossTimeArr(), and getWossTimeArr().
|
protected |
pthread id associated to the creation croller thread
|
protected |
The computation of current queries
Referenced by getWossPressure(), getWossPressure(), and insertThreadReplyPressure().
|
protected |
Storage for current queries
Referenced by getWossPressure(), getWossPressure(), getWossTimeArr(), getWossTimeArr(), initThreadVars(), and popThreadParamIndex().
|
protected |
The computation of current queries
Referenced by getWossTimeArr(), getWossTimeArr(), and insertThreadReplyTimeArr().
|
protected |
Number of queries
Referenced by getWossPressure(), getWossPressure(), getWossTimeArr(), getWossTimeArr(), and initThreadVars().
|
protected |
Number of created threads
Referenced by getWossPressure(), getWossPressure(), getWossTimeArr(), getWossTimeArr(), and initThreadVars().
|
protected |
Total number of completed threads
Referenced by getWossPressure(), getWossPressure(), getWossTimeArr(), getWossTimeArr(), and initThreadVars().