|
MASA-Core
|
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>
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_t > | dispatcherQueue |
Definition at line 27 of file AbstractAlignerSafe.cpp.
| AbstractAlignerSafe::~AbstractAlignerSafe | ( | ) | [virtual] |
Definition at line 33 of file AbstractAlignerSafe.cpp.
| void AbstractAlignerSafe::createDispatcherQueue | ( | ) | [protected] |
Definition at line 70 of file AbstractAlignerSafe.cpp.
| void AbstractAlignerSafe::destroyDispatcherQueue | ( | ) | [protected] |
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.
| j | the column to be dispatched. |
| buffer | the vector containing the data (starting from cell 0). |
| len | the number of cells that will be read from the vector. |
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.
| i | the row to be dispatched. |
| buffer | the vector containing the data (starting from cell 0). |
| len | the number of cells that will be read from the vector. |
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.
| score | the score to be dispatched |
| bx | the block position in the horizontal direction, starting from 0 up to AbstractAligner::getGridWidth() minus 1. |
| by | the block position in the vertical direction, starting from 0 up to AbstractAligner::getGridHeight() minus 1. |
Reimplemented from AbstractAligner.
Definition at line 49 of file AbstractAlignerSafe.cpp.
| void AbstractAlignerSafe::executeLoop | ( | ) | [private] |
Definition at line 102 of file AbstractAlignerSafe.cpp.
| void * AbstractAlignerSafe::staticFunctionThread | ( | void * | arg | ) | [static, private] |
Definition at line 96 of file AbstractAlignerSafe.cpp.
pthread_cond_t AbstractAlignerSafe::condition [private] |
Definition at line 79 of file AbstractAlignerSafe.hpp.
queue<dispatch_job_t> AbstractAlignerSafe::dispatcherQueue [private] |
Definition at line 81 of file AbstractAlignerSafe.hpp.
bool AbstractAlignerSafe::dispatcherQueueActive [private] |
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.
1.7.6.1