>>
>> I would think that even with a retain it could get weird...
>>
>> The main thread wants to use the imageRef property so it calls:
>>
>> myRef = [window.imageRef];
>> [myref retain];
>>
>> If right between these calls, the worker thread calls setImageRef (on a
>> property with atomic,
>
> I would think that even with a retain it could get weird...
>
> The main thread wants to use the imageRef property so it calls:
>
> myRef = [window.imageRef];
> [myref retain];
>
> If right between these calls, the worker thread calls setImageRef (on a
> property with atomic, copy), then
>
>> On 27 Jul 2016, at 12:05 PM, Trygve Inda wrote:
>>
>> How is it retained by the main thread without an explicit retain call?
>>
>> I would be no different than a main thread calling:
>>
>> someVar [[MyObj alloc] init]
>> [someVar doSomething];
>>
>> If a worker
>
>> On 27 Jul 2016, at 10:05, Trygve Inda wrote:
>>
>>>
>>
>> How is it retained by the main thread without an explicit retain call?
>
> are you not using ARC? If you are then all such references, both variable and
> during method calls are retained automatically.
> On 27 Jul 2016, at 10:05, Trygve Inda wrote:
>
>>
>
> How is it retained by the main thread without an explicit retain call?
are you not using ARC? If you are then all such references, both variable and
during method calls are retained automatically. If you’re
> On 27 Jul 2016, at 12:18 PM, Graham Cox wrote:
>
> The atomic setter method probably looks something like this:
A further thought. If the getter method is also protected, like:
- (NSImageRep*) imageRep
{
@synchronized( self )
{
return
> On 27 Jul 2016, at 12:05 PM, Trygve Inda wrote:
>
> How is it retained by the main thread without an explicit retain call?
>
> I would be no different than a main thread calling:
>
> someVar [[MyObj alloc] init]
> [someVar doSomething];
>
> If a worker thread were
>
>> On 27 Jul 2016, at 09:33, Trygve Inda wrote:
>>
>>
>>
>> If the worker thread calls window.imageRep = myResult; it is possible that
>> the main thread is in the middle of a call like:
>>
>> [[window.imageRep]
>>
> On 27 Jul 2016, at 09:33, Trygve Inda wrote:
>
>
>
> If the worker thread calls window.imageRep = myResult; it is possible that
> the main thread is in the middle of a call like:
>
> [[window.imageRep]
>
> e.g.
>
> worker thread:
>
> while( self.running )
> {
> // do work
>
> window.imageRep = myResult; // window.imageRep is (atomic, copy)
>
> [performOnMainThread: window.setNeedsDisplay]; // this is obviously
> pseudocode!
> }
>
>
> main thread, when it needs to terminate worker
> On 23 Jul 2016, at 4:09 PM, Ken Thomases wrote:
>
> No, because the main thread may not have started servicing the
> performSelector request yet. The background thread has blocked as soon as
> the request is _queued_ for the main thread, not just once the main thread
> On Jul 22, 2016, at 19:29 , Graham Cox wrote:
>>
>> If the worker thread is waiting for -performOnMainThread to complete, it
>> *cannot* possibly get a call from the main thread to terminate
>
> I nodded agreement when I first read this, then “but wait!” …
>
> Your
On Jul 22, 2016, at 9:29 PM, Graham Cox wrote:
>
>
>> On 23 Jul 2016, at 12:45 AM, Trygve Inda wrote:
>>
>> Because the main thread sometimes needs to ask the worker threads to
>> terminate. If it does this after performOnMainThread has been
On Jul 22, 2016, at 19:29 , Graham Cox wrote:
>
> If the worker thread is waiting for -performOnMainThread to complete, it
> *cannot* possibly get a call from the main thread to terminate
I nodded agreement when I first read this, then “but wait!” …
Your logic seems
> On 23 Jul 2016, at 12:45 AM, Trygve Inda wrote:
>
> Because the main thread sometimes needs to ask the worker threads to
> terminate. If it does this after performOnMainThread has been called by a
> worker thread, but before the main thread has processed it, then the
Or better yet, have the termination request come from a thread other than the
main thread.
> On Jul 22, 2016, at 9:38 AM, Alan Snyder wrote:
>
>
>> On Jul 22, 2016, at 7:45 AM, Trygve Inda wrote:
>>
>> Because the main thread sometimes
> On Jul 22, 2016, at 7:45 AM, Trygve Inda wrote:
>
> Because the main thread sometimes needs to ask the worker threads to
> terminate. If it does this after performOnMainThread has been called by a
> worker thread, but before the main thread has processed it, then the
>> Currently it blocks at this point, but I need to avoid that.
>
> It’s not really clear why this needs to be avoided. The time to draw the
> pixels should be a few milliseconds, a small fraction of the time your thread
> needs to run, even at its fastest.
Because the main thread sometimes
> On 22 Jul 2016, at 11:53 PM, Trygve Inda wrote:
>
> How can I draw the NSImageRep directly into a window?
-[NSImageRep drawInRect:fromRect:operation:fraction:respectFlipped:hints:];
i.e. same as NSImage.
>
> Also, the main pixel buffer is updated slowly (it
>
>> On 22 Jul 2016, at 4:08 PM, Trygve Inda wrote:
>>
>> I don't think the second part will work because of my workflow:
>>
>> At Launch: Create pixel buffer that is 1000 x 1000 pixels
>>
>> Looping thread
>> 1. Fill pixel buffer with pixels based on some algorithm
>> This is how it works now, but we are running into a rare deadlock situation
>> where the main thread asks the worker thread to end (and waits until it does
>> so) while the worker thread is waiting for the image to be displayed.
>
> If the window has a imageRep property that is (atomic,
> On 22 Jul 2016, at 5:30 PM, Quincey Morris
> wrote:
>
> On Jul 22, 2016, at 00:08 , Graham Cox wrote:
>>
>> If the thread building images never goes faster than once per second, the
>> time to draw the image is a fraction of
On Jul 22, 2016, at 00:08 , Graham Cox wrote:
>
> If the thread building images never goes faster than once per second, the
> time to draw the image is a fraction of that - I’m sure 60fps is achievable,
> so making the thread wait for the drawing to be done isn’t going
>
>> On 22 Jul 2016, at 4:40 PM, Trygve Inda wrote:
>>
>>
>>> With half an eye on performance, if you *do* strictly need a copy of the
>>> bitmap, note that NSBitmapImageRep conforms to NSCopying. You don’t have to
>>> turn it into a TIFF and back again.
>>>
>>>
> On 22 Jul 2016, at 5:00 PM, Roland King wrote:
>
> Since you need the data to persist for display whilst you write a new image
> that means there’s two separate buffers, there has to be
Not sure there HAS to be. Whether it’s the easiest approach is another matter.
If the
> On 22 Jul 2016, at 14:40, Trygve Inda wrote:
>
>
>> With half an eye on performance, if you *do* strictly need a copy of the
>> bitmap, note that NSBitmapImageRep conforms to NSCopying. You don’t have to
>> turn it into a TIFF and back again.
>>
>> Also, you don’t
> On 22 Jul 2016, at 4:40 PM, Trygve Inda wrote:
>
>
>> With half an eye on performance, if you *do* strictly need a copy of the
>> bitmap, note that NSBitmapImageRep conforms to NSCopying. You don’t have to
>> turn it into a TIFF and back again.
>>
>> Also, you
> With half an eye on performance, if you *do* strictly need a copy of the
> bitmap, note that NSBitmapImageRep conforms to NSCopying. You don’t have to
> turn it into a TIFF and back again.
>
> Also, you don’t even need an NSImage - the NSImageRep can be drawn directly.
A little deeper
> On 22 Jul 2016, at 4:08 PM, Trygve Inda wrote:
>
> I don't think the second part will work because of my workflow:
>
> At Launch: Create pixel buffer that is 1000 x 1000 pixels
>
> Looping thread
> 1. Fill pixel buffer with pixels based on some algorithm
> 2.
On Jul 22, 2016, at 1:08 AM, Trygve Inda wrote:
>
>> But that’s not a great way to do this. You’ve made an image, you’ve encoded
>> it
>> as TIFF data, then you’ve made a new image, which has decoded the TIFF data
>> to
>> make a new image rep/bitmap.
>>
>> You could
>
>> On 22 Jul 2016, at 3:37 PM, Trygve Inda wrote:
>>
>> I create an NSBitmapImageRep:
>>
>> [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
>> pixelsWide:pixelSize.width
>> pixelsHigh:pixelSize.height
>> bitsPerSample:8
>> samplesPerPixel:4
>> hasAlpha:YES
On Jul 22, 2016, at 12:37 AM, Trygve Inda wrote:
>
> I create an NSBitmapImageRep:
>
> [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
> pixelsWide:pixelSize.width
> pixelsHigh:pixelSize.height
> bitsPerSample:8
> samplesPerPixel:4
> hasAlpha:YES
> isPlanar:NO
> On 22 Jul 2016, at 3:37 PM, Trygve Inda wrote:
>
> I create an NSBitmapImageRep:
>
> [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
> pixelsWide:pixelSize.width
> pixelsHigh:pixelSize.height
> bitsPerSample:8
> samplesPerPixel:4
> hasAlpha:YES
>
I create an NSBitmapImageRep:
[[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:pixelSize.width
pixelsHigh:pixelSize.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
34 matches
Mail list logo