World Ocean Simulation System (WOSS) library
woss::WossManagerResDbMT Class Reference

Multi-threaded extension of WossManagerResDb. More...

#include <woss-manager.h>

Inheritance diagram for woss::WossManagerResDbMT:
Inheritance graph
Collaboration diagram for woss::WossManagerResDbMT:
Collaboration graph

Classes

struct  ThreadCondSignal
 
struct  ThreadParam
 
struct  ThreadQuery
 

Public Member Functions

 WossManagerResDbMT ()
 
virtual PressuregetWossPressure (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value)
 
virtual PressuregetWossPressure (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, double time_value)
 
virtual TimeArrgetWossTimeArr (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value)
 
virtual TimeArrgetWossTimeArr (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
virtual PressuregetWossPressure (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value)
 
virtual TimeArrgetWossTimeArr (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value)
 
WossManagerResDbsetWossDbManager (const WossDbManager *const ptr)
 
- Public Member Functions inherited from woss::WossManager
 WossManager ()
 
virtual const WossgetActiveWoss (const CoordZ &tx, const CoordZ &rx, double start_frequency, double end_frequency) const
 
virtual WossManagereraseActiveWoss (const CoordZ &tx, const CoordZ &rx, double start_frequency, double end_frequency)=0
 
virtual PressuregetWossPressure (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value)=0
 
virtual PressuregetWossPressure (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, double time_value=0.0)
 
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=0.0)
 
virtual TimeArrgetWossTimeArr (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, const Time &time_value)=0
 
virtual TimeArrgetWossTimeArr (const CoordZ &tx_coordz, const CoordZ &rx_coordz, double start_frequency, double end_frequency, double time_value=0.0)
 
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=0.0)
 
virtual bool reset ()=0
 
virtual bool timeEvolve (const Time &time_value)=0
 
WossManagersetWossCreator (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, ThreadParamThreadParamIndex
 
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
TimeArrdbGetTimeArr (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
 
PressuredbGetPressure (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 WossDbManagerwoss_db_manager
 
- Protected Attributes inherited from woss::WossManager
const WossCreatorwoss_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)
 

Detailed Description

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.

Member Typedef Documentation

◆ ThreadParamIndex

typedef ::std::pair< int, ThreadParam > woss::WossManagerResDbMT::ThreadParamIndex
protected

Type used by an active query thread

Constructor & Destructor Documentation

◆ WossManagerResDbMT()

WossManagerResDbMT::WossManagerResDbMT ( )

WossManagerResDbMT default constructor

References checkConcurrentThreads(), max_thread_number, mutex, and request_mutex.

Here is the call graph for this function:

Member Function Documentation

◆ checkConcurrentThreads()

void WossManagerResDbMT::checkConcurrentThreads ( )
protected

Sets concurrent_threads valid range

References concurrent_threads, and max_thread_number.

Referenced by setConcurrentThreads(), and WossManagerResDbMT().

◆ getConcurrentThreads()

int woss::WossManagerResDbMT::getConcurrentThreads ( )
inline

Gets the number of concurrent threads

Returns
number of concurrent threads

References concurrent_threads.

◆ getWossPressure() [1/4]

Pressure * WossManagerResDbMT::getWossPressure ( const CoordZ tx_coordz,
const CoordZ rx_coordz,
double  start_frequency,
double  end_frequency,
const Time time_value 
)
virtual

◆ getWossPressure() [2/4]

Pressure * WossManagerResDbMT::getWossPressure ( const CoordZ tx_coordz,
const CoordZ rx_coordz,
double  start_frequency,
double  end_frequency,
double  time_value 
)
virtual

Returns a valid Pressure for given parameters

Parameters
txconst reference to a valid CoordZ object ( transmitter )
rxconst reference to a valid CoordZ object ( receiver )
start_freqstart frequency [Hz]
end_freqend frequency [Hz]
time_valuenumber of seconds after start time
Returns
valid Pressure value

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.

Here is the call graph for this function:

◆ getWossPressure() [3/4]

PressureVector WossManagerResDbMT::getWossPressure ( const CoordZPairVect coordinates,
double  start_frequency,
double  end_frequency,
const Time time_value 
)
virtual

Returns a valid vector of Pressure* for given parameters

Parameters
coordinatesconst reference to a valid CoordZPairVect
start_freqstart frequency [Hz]
end_freqend frequency [Hz]
time_valueconst reference to a valid Time object
Returns
valid PressureVector

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.

Here is the call graph for this function:

◆ getWossPressure() [4/4]

PressureVector WossManagerResDbMT::getWossPressure ( const CoordZPairVect coordinates,
double  start_frequency,
double  end_frequency,
double  time_value 
)
virtual

Returns a valid vector of Pressure* for given parameters

Parameters
coordinatesconst reference to a valid CoordZPairVect
start_freqstart frequency [Hz]
end_freqend frequency [Hz]
time_valuenumber of seconds after start time
Returns
valid PressureVector

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.

Here is the call graph for this function:

◆ getWossTimeArr() [1/4]

TimeArr * WossManagerResDbMT::getWossTimeArr ( const CoordZ tx_coordz,
const CoordZ rx_coordz,
double  start_frequency,
double  end_frequency,
const Time time_value 
)
virtual

◆ getWossTimeArr() [2/4]

TimeArr * WossManagerResDbMT::getWossTimeArr ( const CoordZ tx_coordz,
const CoordZ rx_coordz,
double  start_frequency,
double  end_frequency,
double  time_value 
)
virtual

Returns a valid TimeArr for given parameters

Parameters
txconst reference to a valid CoordZ object ( transmitter )
rxconst reference to a valid CoordZ object ( receiver )
start_freqstart frequency [Hz]
end_freqend frequency [Hz]
time_valuenumber of seconds after start time
Returns
valid TimeArr value

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.

Here is the call graph for this function:

◆ getWossTimeArr() [3/4]

TimeArrVector WossManagerResDbMT::getWossTimeArr ( const CoordZPairVect coordinates,
double  start_frequency,
double  end_frequency,
const Time time_value 
)
virtual

Returns a valid vector of TimeArr* for given parameters

Parameters
coordinatesconst reference to a valid CoordZPairVect
start_freqstart frequency [Hz]
end_freqend frequency [Hz]
time_valueconst reference to a valid Time object
Returns
valid TimeArrVector

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.

Here is the call graph for this function:

◆ getWossTimeArr() [4/4]

TimeArrVector WossManagerResDbMT::getWossTimeArr ( const CoordZPairVect coordinates,
double  start_frequency,
double  end_frequency,
double  time_value 
)
virtual

Returns a valid vector of TimeArr* for given parameters

Parameters
coordinatesconst reference to a valid CoordZPairVect
start_freqstart frequency [Hz]
end_freqend frequency [Hz]
time_valuenumber of seconds after start time
Returns
valid TimeArrVector

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.

Here is the call graph for this function:

◆ initThreadVars()

void WossManagerResDbMT::initThreadVars ( )
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(), and getWossTimeArr().

◆ insertThreadReplyPressure()

void WossManagerResDbMT::insertThreadReplyPressure ( int  index,
woss::Pressure pressure 
)
protected

Insert the given Pressure pointer in the PressureVector reply at given index

Parameters
indexvector index
pressurepointer to a heap-created Pressure

References mutex, and thread_pressure_reply.

Referenced by woss::WMSMTcreateThreadPressure().

◆ insertThreadReplyTimeArr()

void WossManagerResDbMT::insertThreadReplyTimeArr ( int  index,
woss::TimeArr time_arr 
)
protected

Insert the given TimeArr pointer in the TimeArrVector reply at given index

Parameters
indexvector index
time_arrpointer to a heap-created TimeArr

References mutex, and thread_time_arr_reply.

Referenced by woss::WMSMTcreateThreadTimeArr().

◆ popThreadParamIndex()

WossManagerResDbMT::ThreadParamIndex WossManagerResDbMT::popThreadParamIndex ( )
protected

Returns a valid ThreadParamIndex for a requesting thread

Returns
valid ThreadParamIndex

References woss::WossManager::debug, mutex, and thread_query.

Referenced by woss::WMSMTcreateThreadPressure(), and woss::WMSMTcreateThreadTimeArr().

◆ setConcurrentThreads()

void woss::WossManagerResDbMT::setConcurrentThreads ( int  number)
inline

Sets the number of concurrent threads. If number < 0 multi-threading is disabled. If number = 0 the thread number is automatically handled.

Parameters
numbernumber of concurrent threads

References checkConcurrentThreads(), and concurrent_threads.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ WMSMTcreateThreadPressure

void * WMSMTcreateThreadPressure ( void *  ptr)
friend

Function used for Pressure thread creation

Parameters
ptrvoid pointer
Returns
void pointer

Referenced by getWossPressure().

◆ WMSMTcreateThreadTimeArr

void * WMSMTcreateThreadTimeArr ( void *  ptr)
friend

Function used for TimeArr thread creation

Parameters
ptrvoid pointer
Returns
void pointer

Referenced by getWossTimeArr().

Member Data Documentation

◆ active_woss

ActiveWoss woss::WossManagerResDbMT::active_woss
protected

Set of current active Woss objects

Referenced by getWossPressure(), and getWossTimeArr().

◆ concurrent_threads

int woss::WossManagerResDbMT::concurrent_threads
protected

◆ max_thread_number

int woss::WossManagerResDbMT::max_thread_number
protected

Max number of created threads

Referenced by checkConcurrentThreads(), and WossManagerResDbMT().

◆ mutex

pthread_spinlock_t woss::WossManagerResDbMT::mutex
protected

◆ request_mutex

pthread_spinlock_t woss::WossManagerResDbMT::request_mutex
protected

Secondary spinlock

Referenced by getWossPressure(), getWossTimeArr(), and WossManagerResDbMT().

◆ thread_arr

pthread_t woss::WossManagerResDbMT::thread_arr[MAX_TOTAL_PTHREAD]
protected

Array of pthread ids associated to the created query threads

Referenced by getWossPressure(), and getWossTimeArr().

◆ thread_controller

pthread_t woss::WossManagerResDbMT::thread_controller
protected

pthread id associated to the creation croller thread

◆ thread_pressure_reply

PressureVector woss::WossManagerResDbMT::thread_pressure_reply
protected

The computation of current queries

Referenced by getWossPressure(), and insertThreadReplyPressure().

◆ thread_query

ThreadQuery woss::WossManagerResDbMT::thread_query
protected

Storage for current queries

Referenced by getWossPressure(), getWossTimeArr(), initThreadVars(), and popThreadParamIndex().

◆ thread_time_arr_reply

TimeArrVector woss::WossManagerResDbMT::thread_time_arr_reply
protected

The computation of current queries

Referenced by getWossTimeArr(), and insertThreadReplyTimeArr().

◆ total_queries

int woss::WossManagerResDbMT::total_queries
protected

Number of queries

Referenced by getWossPressure(), getWossTimeArr(), and initThreadVars().

◆ total_thread_created

volatile int woss::WossManagerResDbMT::total_thread_created
protected

Number of created threads

Referenced by getWossPressure(), getWossTimeArr(), and initThreadVars().

◆ total_thread_ended

volatile int woss::WossManagerResDbMT::total_thread_ended
protected

Total number of completed threads

Referenced by getWossPressure(), getWossTimeArr(), and initThreadVars().


The documentation for this class was generated from the following files: