Commit b83192a5 authored by Marek Vavrusa's avatar Marek Vavrusa

Extended DThreads API with dt_start_id(), bugfixes.

* Finally no threading errors or wrong locking orders.
* Updated tests.

Commit refs #53, #50.
parent d752e091
This diff is collapsed.
......@@ -149,6 +149,13 @@ int dt_resize(dt_unit_t *unit, int size);
*/
int dt_start (dt_unit_t *unit);
/*!
* \brief Start given thread.
*
* \return On success: 0, else <0
*/
int dt_start_id (dthread_t *thread);
/*!
* \brief Send given signal to thread.
*
......@@ -257,6 +264,23 @@ int dt_optimal_size ();
*/
int dt_is_cancelled (dthread_t *thread);
/*!
* \brief Lock unit to prevent parallel operations which could alter unit
* at the same time.
*
* \return On success: 0, else <0
*/
int dt_unit_lock(dt_unit_t *unit);
/*!
* \brief Unlock unit.
*
* \see dt_unit_lock()
*
* \return On success: 0, else <0
*/
int dt_unit_unlock(dt_unit_t *unit);
#endif // DTHREADS_H
/** @} */
......@@ -139,14 +139,12 @@ static inline int dt_test_resize(dt_unit_t *unit, int size)
}
// Repurpose all
_runnable_i = 0;
for (int i = 0; i < size; ++i) {
ret += dt_repurpose(unit->threads[i], &runnable, 0);
ret += dt_start_id(unit->threads[i]);
}
// Restart
_runnable_i = 0;
ret += dt_start(unit);
// Wait for finish
ret += dt_join(unit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment