Instance Method
readNavigatorTree(timeout:delay:queue:broadcast:)
Read a tree on disk from a given path. The read is atomically performed, which means it reads all the content of the file from the disk and process the tree from loaded data. The queue is used to load the data for a given timeout period, after that, the queue is used to schedule another read after a given delay. This approach ensures that the used queue doesn’t stall while loading the content from the disk keeping the used queue responsive.
func readNavigatorTree(timeout: TimeInterval, delay: TimeInterval = 0.01, queue: DispatchQueue, broadcast: NavigatorTree.BroadcastCallback?) throws
Parameters
timeoutThe duration for which we can load a batch of items from data. Once the timeout duration passes, the reading process will reschedule asynchronously using the given queue.
delayThe duration to wait for before scheduling the next read. Default: 0.01 seconds.
queueThe queue to use.
broadcastThe callback to receive updates on the status of the current process.
Discussion
Note
Do not access the navigator tree root node or the map from identifier to node from a different thread than the one the queue is using while the read is performed, this may cause data inconsistencies. For that please use the broadcast callback that notifies which items have been loaded.