• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Better sorting using threads?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Better sorting using threads?


  • Subject: Better sorting using threads?
  • From: Graham Cox <email@hidden>
  • Date: Thu, 11 Mar 2010 16:50:34 +1100

I've got a situation where sorting an array using sort descriptors is slow. The number of items being sorted is not enormous - about 2,000 - but there could be several sort descriptors and the main string one is using a localized and natural numeric comparison. I cache the results and take a lot of care only to resort when needed, but that doesn't help on the first run through which often takes in the order of 10-20 seconds. The interface that displays the results therefore beachballs for this time.

I'm considering using threads to help, where a thread is used to perform the sort itself, and until the sort has finished the UI can display a busy indicator (indeterminate circular progress indicator) next to the selected row in the table. This is in the master table of a master-detail interface where the detail displays the sorted items selected. While busy the detail view can be blank or show the previous arrangement.

So my question is, is threading a good solution? While NSMutableArray isn't marked as thread-safe, the array in question can be arranged to not be used outside of the sorting thread, and only substituted for the returned sorted items when complete. Or can array sorting not be done on a thread at all?

 --Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Better sorting using threads?
      • From: Ken Thomases <email@hidden>
  • Prev by Date: The Location of the Service Menu
  • Next by Date: Re: Better sorting using threads?
  • Previous by thread: The Location of the Service Menu
  • Next by thread: Re: Better sorting using threads?
  • Index(es):
    • Date
    • Thread