Coder Social home page Coder Social logo

concurrentcollectionoperations's Introduction

Concurrent Collection Operations

A set of categories for performing concurrent map and filter operations on Foundation data structures. NSArray, NSDictionary, NSSet, NSOrderedSet, and NSMapTable (OS X) are currently supported.

Concurrency is achieved using Grand Central Dispatch's dispatch_apply. By default, operations are run on the default priority global concurrent queue (DISPATCH_QUEUE_PRIORITY_DEFAULT). The operations can be performed on any concurrent queue, see the category header files.

Please note that using this code could actually result in slower performance. For example, if a map or filter operation uses up a large amount of memory, then performing it concurrently could cause memory thrashing. Currently, this API does not offer a way to limit the amount of concurrency, but doing so explicitly with dispatch_semaphore is straight forward.

This library is based off code and ideas from @alloy and @seanlilmateus.

Installation

Install via CocoaPods, or by adding the Xcode project to your project.

Examples

These examples are taken from the tests.

Doubling the values of an array:

NSArray *doubled = [numbersArray cco_concurrentMap:^(NSNumber *number) {
    return @(2 * number.unsignedIntegerValue);
}];

Filtering even numbers out of a dictionary:

NSDictionary *filtered = [numbersDictionary cco_concurrentFilter:^BOOL (NSNumber *number) {
    return number.unsignedIntegerValue % 2 == 1;
}];

Contributors

ConcurrentCollectionOperations has been made by @alloy, @CodaFi, @jballanc, @kastiglione, and @seanlilmateus.

TODO

  1. Write heavier/stressing tests.

License

Concurrent Collection Operations is released under the MIT License. See LICENSE.txt.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

concurrentcollectionoperations's People

Contributors

alloy avatar codafi avatar jballanc avatar kastiglione avatar seanlilmateus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

concurrentcollectionoperations's Issues

Memory pressure handling

As brought to attention in #2, concurrently executing memory intensive tasks can be detrimental to performance.

  • Document issue in README.
  • Provide API to limit number of tasks?
  • Use new GCD API to detect memory pressure and respond by scaling down concurrency?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.