In my current project, we are using a 3rd party library which is designed to run only from a single tread. But our project is multi-threaded. I don't know if it is very common but I did the simplest thing to solve the race conditions.
I come up with a design in which our threads have to ask a specific single thread for this thread-unsafe call. For example we already had thread A and B, and now I come up with a thread C. And if A or B wants the calculation they have to ask from C. C will reply only one at one time and that is fine even A and B will be blocked if one of them already is asked and waiting for C to complete.
I wanted to implement that with conditional variables but I am still having deadlocks. Can you please see my example which I removed my extra data structures and tell me if I should change my approach or if you see a part which might cause deadlocks can you please give your suggestions about that parts of the code.
Aucun commentaire:
Enregistrer un commentaire