NDSStoreAccessSync

public class NDSStoreAccessSync

Synchronizes access to an onboard NDS map.

An object of this class acts as a kind of a reader/writer lock, in that it allows any number of concurrent readers to access the map at the same time, or one writer and nobody else. It also offers facilities for writers to notify all current readers that the map needs to be modified so they (the readers) can ‘let go’. After the writer has finished modifying the map, NDSStoreAccessSync will dispatch notifications to all others to let them know the map is accessible once again.

  • Registers an observer so it can be informed about changes in map availability. Caller must register their observer in order to get onReadOnlyAccessGranted access If the caller does not add an observer read access will not be granted . If the map is already available at the time of calling this, onReadOnlyAccessGranted will be called immediately, before this call returns. Caller of this function must not hold the same synchronisation primitive (mutex, lock or similar) which will be held inside callbacks inherited from ‘StoreAccessChangedObserver’. Otherwise, a deadlock may occur!

    Declaration

    Swift

    public func addObserver(_ observer: StoreAccessChangedObserver)

    Parameters

    observer

    observer to add.

  • Unregisters an observer (if it was previously registered by addObserver).

    After this function returns, it is guaranteed that no more callbacks will be received by this observer.

    Caller of this function must not hold the same synchronisation primitive (mutex, lock or similar) which will be held inside callbacks inherited from ‘StoreAccessChangedObserver’. Otherwise, a deadlock may occur!

    Declaration

    Swift

    public func removeObserver(_ observer: StoreAccessChangedObserver)

    Parameters

    observer

    observer to remove.