Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sync issues with FuturesUnordered #2054

Merged
merged 1 commit into from Jan 29, 2020

Commits on Jan 29, 2020

  1. Fix Sync issues with FuturesUnordered

    This updates non-mutable FuturesUnordered methods to be thread-safe,
    ensuring that Sync trait requirements are met without breaking existing
    functionality.
    
    The FuturesUnordered::link method used by FuturesUnordered::push has
    been modified to use atomic operations to allow for lock-free insertion
    of new futures while still allowing FuturesUnordered::iter and
    IterPinRef itself to operate simultaneously. FuturesUnordered::len has
    been removed, with each Task now storing a snapshot of the list length
    at the time when the future was added, so a synchronized list length can
    always be read after an atomic load of FuturesUnordered::head_all. This
    increases the memory overhead of each task slightly, but it allows us to
    retain the original iterator behavior without dramatically increasing
    the performance cost.
    
    Operations that require mutable FuturesUnordered access have not been
    made lock-free, with direct mutable access to otherwise atomic values
    used when possible to avoid unnecessary overhead.
    okready committed Jan 29, 2020
    Copy the full SHA
    2d73173 View commit details
    Browse the repository at this point in the history