Overview:
-
The done() method of the TopologicalSorter class marks a node of a Directed Acyclic Graph(DAG) as visited.
-
As all the nodes of the DAG are marked as visited, a TopologicalSorter instance becomes inactive. For example, as a workflow gets complete the workflow becomes inactive.
Example:
# A Python example for the parallel sorting # The queues # Worker thread function # Create a worker thread # Start the worker thread # Citation graph as a Directed Acyclic Graph(DAG) # Loop through the documents # Mark the visited document node as done # Main thread waiting for worker threads to finish |
Output:
Worker Thread id:3169172 Main Thread id:3169171 Worker Thread id:3169172 Main Thread id:3169171 Worker Thread id:3169172 From the main thread:D1 Main Thread id:3169171 Worker Thread id:3169172 From the main thread:D3 Main Thread id:3169171 From the main thread:D2 Worker Thread id:3169172 From the main thread:D4 Main Thread id:3169171 Worker Thread id:3169172 From the main thread:D5 Main Thread id:3169171 Main Thread id:3169171 Worker Thread id:3169172 From the main thread:D6 Worker Thread id:3169172 From the main thread:D7 |