Code Monkey home page Code Monkey logo

Comments (3)

heardrwt avatar heardrwt commented on July 26, 2024

Feel free to give this branch a go. It switches out the thread for a GCD queue.
https://github.com/heardrwt/RHAddressBook/tree/gcd-thread-safety

from rhaddressbook.

tonyxiao avatar tonyxiao commented on July 26, 2024

Ok, I'll give it a try whenever I get a chance. Took a look at the GCD branch real quick and kind of worried about all the use of dispatch_sync though. I think a better way of managing concurrency is to follow FMDB's style. Assume single-threaded access but providing optional capability to synchronize concurrent access.

https://github.com/ccgus/fmdb

Meanwhile by the way, i was able to get a performance speedup of 2x by batching operations together to perform on the address book thread.

    [book performAddressBookAction:^(ABAddressBookRef addressBookRef) {
        NSArray *people = [book peopleOrderedByUsersPreference];
        for (RHPerson *person in people) {
            person.firstName;
            person.lastName;
            person.phoneNumbers;
            person.emails;
        }
        NSTimeInterval taken = [[NSDate date] timeIntervalSinceDate:date];
        NSLog(@"rhaddressbook took %f seconds %ld", taken, (long)people.count);
    } waitUntilDone:NO];

Logs


2013-10-20 12:43:20.061 [830:60b] abaddressbook took 0.034871 seconds 779
2013-10-20 12:43:20.279 [830:6b0b] rhaddressbook took 0.217319 seconds 779

from rhaddressbook.

heardrwt avatar heardrwt commented on July 26, 2024

GCD branch is now on master.

from rhaddressbook.

Related Issues (20)

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.