• 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
Re: Concurrent loading of images ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Concurrent loading of images ?


  • Subject: Re: Concurrent loading of images ?
  • From: Sandor Szatmari via Cocoa-dev <email@hidden>
  • Date: Fri, 8 May 2020 18:11:33 -0400

> On May 8, 2020, at 15:13, Rob Petrovec via Cocoa-dev
> <email@hidden> wrote:
>
> 
>
>>> On May 8, 2020, at 12:19 PM, Jens Alfke via Cocoa-dev
>>> <email@hidden> wrote:
>>>
>>>
>>>
>>>> On May 8, 2020, at 9:53 AM, Gabriel Zachmann via Cocoa-dev
>>>> <email@hidden> wrote:
>>>
>>> So, I was thinking, maybe it helps to load the next image concurrently,
>>> while the current one is still being displayed.
>>
>> Sure. Just be aware that if you're using NSImage, simply loading an NSImage
>> does not rasterize it; the class tries to be 'lazy' about doing work. So
>> your background task should explicitly render it, e.g. into an
>> NSBitmapImageRep.
>>
>>> I also read about the GCD's dispatch queues, but it seems to me that this
>>> would not be the suitable approach since I always only have one task
>>> running concurrently to the main thread.
>>
>> Why not? Dispatch queues are always available. (The main thread is simply a
>> special queue.) You can run the background task by creating a single
>> dispatch queue and then using dispatch_async to call a block that does the
>> work. The end of the block would call dispatch_async back to the main queue
>> and pass the image as a parameter.
>    I second the use of GCD.  Its also considerably simpler than NSThread,
> NSOperationQueue/NSOperation et al.  This is the kind of operation that GCD
> was invented for.

I would add, that for a long running process, open ended work, or task, I would
favor a thread.  But for short and finite items I would favor
GCD/NSOperationQueue.

Are you going to only load one image, the next image, in this concurrent
loading scenario?  Or, will you be loading many images and caching them?

I would imaging looking one or two ahead would be the choice.  I’m just trying
to understand the need/use case.  If there’s lots of overhead that can be
reduced to a one time effort than maybe a thread is better.  If not maybe a
one-off throw-it-in-a-queue and be done with it approach is better?

Sandor

>
> —Rob
>
>
> _______________________________________________
>
> 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
_______________________________________________

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: Concurrent loading of images ?
      • From: Gabriel Zachmann via Cocoa-dev <email@hidden>
References: 
 >Re: Concurrent loading of images ? (From: Rob Petrovec via Cocoa-dev <email@hidden>)

  • Prev by Date: Re: Concurrent loading of images ?
  • Next by Date: Re: Concurrent loading of images ?
  • Previous by thread: Re: Concurrent loading of images ?
  • Next by thread: Re: Concurrent loading of images ?
  • Index(es):
    • Date
    • Thread