Release the held lock
| 70 | |
| 71 | // Release the held lock |
| 72 | void Graph_ReleaseLock |
| 73 | ( |
| 74 | Graph *g |
| 75 | ) { |
| 76 | ASSERT(g != NULL); |
| 77 | |
| 78 | // set _writelocked to false BEFORE unlocking |
| 79 | // if this is a reader thread no harm done, |
| 80 | // if this is a writer thread the writer is about to unlock so once again |
| 81 | // no harm done, if we set `_writelocked` to false after unlocking it is possible |
| 82 | // for a reader thread to be considered as writer, performing illegal access to |
| 83 | // underline matrices, consider a context switch after unlocking `_rwlock` but |
| 84 | // before setting `_writelocked` to false |
| 85 | g->_writelocked = false; |
| 86 | pthread_rwlock_unlock(&g->_rwlock); |
| 87 | } |
| 88 | |
| 89 | //------------------------------------------------------------------------------ |
| 90 | // Graph utility functions |
no outgoing calls