Skip to content

Add proper enqueuing of Tokens for ArrayHandle

Kenneth Moreland requested to merge kmorel/vtk-m:ordered-async-access into master

An issue that was identified for the thread safety of ArrayHandle is that if several threads are waiting to use an ArrayHandle, there might be an expectation of the order in which the operations happen. For example, if one thread is modifying the contents of an ArrayHandle and another is reading those results, we would need the first one to start before the second one.

To solve this, a queue is added to ArrayHandle such that when waiting to read or write an ArrayHandle the Token has to be at the top of the queue in addition to other requirements being met.

Additionally, an Enqueue method is added to add a Token to the queue without blocking. This allows a control thread to queue the access and then spawn a thread where the actual work will be done. As long as everything is enqueued on the main thread, the operations will happen in the expected order.

Edited by Kenneth Moreland

Merge request reports

Loading