Skip navigation.
 
mlThread safe?
FROM : Trygve Inda
DATE : Sat Mar 29 14:44:56 2008

I am finding it hard to determine in many cases exactly what is thread safe
as this is not complete:

http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/Thr
eadSafetySummary/chapter_950_section_2.html

Can I call the following from a thread?

segImageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
                              pixelsWide:100
                              pixelsHigh:100
                              bitsPerSample:8
                              samplesPerPixel:4
                              hasAlpha:YES
                              isPlanar:NO
                              colorSpaceName:NSDeviceRGBColorSpace
                              bitmapFormat:NSAlphaFirstBitmapFormat
                              bytesPerRow:100 * 4
                              bitsPerPixel:32];
    segBaseAddr = [segImageRep bitmapData];

    [segImageRep dealloc];

How about:

NSImage *    image = [[[NSImage alloc] initWithContentsOfFile:path]
autorelease];

    [NSGraphicsContext saveGraphicsState];
    [NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithBitmapImageRep:segImageRep]];

    [image drawInRect:NSMakeRect(0, 0, [image size].width, [image
size].height) fromRect:NSMakeRect(0, 0, [image size].width, [image
size].height) operation:NSCompositeCopy fraction:1.0];

    [NSGraphicsContext restoreGraphicsState];


I am trying to eliminate as much as possible calls to
detachNewThreadSelector since I can only pass these methods a single object.

Thanks,

Trygve

Related mailsAuthorDate
mlThread safe? Trygve Inda Mar 29, 14:44
mlRe: Thread safe? Jens Alfke Mar 29, 18:05
mlRe: Thread safe? Adam R. Maxwell Mar 29, 18:54
mlRe: Thread safe? Trygve Inda Mar 29, 20:20
mlRe: Thread safe? Adam R. Maxwell Mar 29, 20:48
mlRe: Thread safe? Thomas Engelmeier Mar 30, 15:10
mlRe: Thread safe? Adam R. Maxwell Mar 30, 17:01
mlRe: Thread safe? Trygve Inda Mar 30, 17:34
mlRe: Thread safe? Jens Alfke Mar 30, 19:02
mlRe: Thread safe? glenn andreas Mar 30, 19:14
mlRe: Thread safe? Trygve Inda Mar 30, 22:21
mlRe: Thread safe? glenn andreas Mar 30, 22:35
mlRe: Thread safe? Thomas Engelmeier Mar 31, 12:30