Hi,

I'm new with boost thread, I have some problems.
I have got two methods, one for writing and one for reading my data and I would do this thread-safe.
I have tried to do this with boost::unique_lock<boost::shared_mutex> lock(...), but I have created a deadlock.

For example my methods are called within the threads and set / get data to / from a ublas matrix.

void setData( const size_t row, const size_t col, const size_t data) {
(1*)
_matrix(row, col) = data 
(2*)
}

and 

getData( const size_t row, const size_t col, size_t& a, size_t& b) {
a = _matrix(row, col);
b = _matrix(col, row);
}

How can I do both methods in the correct way thread-safe? 
By reading the matrix data the write method need not to change the values. I have created a unique lock on (1*) and do the unlock on (2*) but this creates the deadlock. Then I have tried it with a scoped_lock on (1*) but the data in the matrix is wrong.

I hope that someone can explain me the correct solution.

Thanks a lot

Phil