MASA-Core
Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
AbstractAlignerSafe Class Reference

Detailed Description

A thread-safe AbstractAligner extension.

The current MASA implementation is not thread-safe. So, if an Aligner executes simultaneous threads, the dispatch methods may generate an inconsistent state leading to segmentation faults. To avoid this behavior, the Aligner must extend the AbstractAlignerSafe class in order to serialize the dispatch calls.

There are two serialization strategies.

Definition at line 63 of file AbstractAlignerSafe.hpp.

#include <AbstractAlignerSafe.hpp>

Inheritance diagram for AbstractAlignerSafe:
AbstractAligner IAligner

List of all members.

Public Member Functions

 AbstractAlignerSafe ()
virtual ~AbstractAlignerSafe ()
virtual void dispatchColumn (int j, const cell_t *buffer, int len)
 Delegates to IManager::dispatchColumn()
virtual void dispatchRow (int i, const cell_t *buffer, int len)
 Delegates to IManager::dispatchRow()
virtual void dispatchScore (score_t score, int bx=-1, int by=-1)
 Delegates to IManager::dispatchScore()

Protected Member Functions

void createDispatcherQueue ()
void destroyDispatcherQueue ()

Private Member Functions

void executeLoop ()

Static Private Member Functions

static void * staticFunctionThread (void *arg)

Private Attributes

pthread_t thread
pthread_mutex_t mutex
pthread_cond_t condition
bool dispatcherQueueActive
queue< dispatch_job_tdispatcherQueue

Constructor & Destructor Documentation

Definition at line 27 of file AbstractAlignerSafe.cpp.

Definition at line 33 of file AbstractAlignerSafe.cpp.


Member Function Documentation

Definition at line 70 of file AbstractAlignerSafe.cpp.

Definition at line 83 of file AbstractAlignerSafe.cpp.

void AbstractAlignerSafe::dispatchColumn ( int  j,
const cell_t buffer,
int  len 
) [virtual]

Delegates to IManager::dispatchColumn()

Notifies to the MASA framework that some cells of a column has been processed.

This function must be called serially for each column. For example, the invocation of dispatchColumn(50000, vector, 100) will dispatch the first 100 cells of the column 50000 to MASA, and the cells are read from the vector[0..99] elements. After this, a call to dispatchColumn(50000, vector, 50) will dispatch the next 50 cells of the same column 5000, and the cells are read from the vector[0..49] elements.

Parameters:
jthe column to be dispatched.
bufferthe vector containing the data (starting from cell 0).
lenthe number of cells that will be read from the vector.
See also:
IManager::dispatchColumn()

Reimplemented from AbstractAligner.

Definition at line 37 of file AbstractAlignerSafe.cpp.

void AbstractAlignerSafe::dispatchRow ( int  i,
const cell_t buffer,
int  len 
) [virtual]

Delegates to IManager::dispatchRow()

Notifies to the MASA framework that some cells of a row has been processed.

This function must be called serially for each row, analogous to the AbstractAligner::dispatchLastColumn method.

Parameters:
ithe row to be dispatched.
bufferthe vector containing the data (starting from cell 0).
lenthe number of cells that will be read from the vector.
See also:
IManager::dispatchRow()

Reimplemented from AbstractAligner.

Definition at line 43 of file AbstractAlignerSafe.cpp.

void AbstractAlignerSafe::dispatchScore ( score_t  score,
int  bx = -1,
int  by = -1 
) [virtual]

Delegates to IManager::dispatchScore()

Notifies to the MASA framework that a new score has been computed.

This method may be called as many times it is necessary, and the best score will be calculated among all calls of this method.

If the Aligner supports the aligner_capabilities_t::dispatch_block_scores capability, them it must dispatch the score with the bx, by parameters set to the block indices and this method must be called only once for each block.

Parameters:
scorethe score to be dispatched
bxthe block position in the horizontal direction, starting from 0 up to AbstractAligner::getGridWidth() minus 1.
bythe block position in the vertical direction, starting from 0 up to AbstractAligner::getGridHeight() minus 1.
See also:
IManager::dispatchScore()

Reimplemented from AbstractAligner.

Definition at line 49 of file AbstractAlignerSafe.cpp.

Definition at line 102 of file AbstractAlignerSafe.cpp.

void * AbstractAlignerSafe::staticFunctionThread ( void *  arg) [static, private]

Definition at line 96 of file AbstractAlignerSafe.cpp.


Member Data Documentation

pthread_cond_t AbstractAlignerSafe::condition [private]

Definition at line 79 of file AbstractAlignerSafe.hpp.

Definition at line 81 of file AbstractAlignerSafe.hpp.

Definition at line 80 of file AbstractAlignerSafe.hpp.

pthread_mutex_t AbstractAlignerSafe::mutex [private]

Definition at line 78 of file AbstractAlignerSafe.hpp.

pthread_t AbstractAlignerSafe::thread [private]

Definition at line 77 of file AbstractAlignerSafe.hpp.


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