On May 11, 2009, at 7:42 PM, Dragan Milić wrote:
So, I assume creating attributed strings is not thread safe, but I don't remember anything like that stated in the documentation. In my opinion, that
looks like a bug.
It is thread safe... if you stick to the Foundation methods. The
method you're trying to use, however, is part of the AppKit additions.
Hence the non-thread safeness.

One way to do this might be to spawn a helper app that accepts data
somehow (mach ports might be fastest using vm copy-on-write techniques
IIRC, but harder to implement), render on that process's main thread,
and then pass the data back (NSAttributedString supports NSCoding).
Would I necessarily need another helper app? Can I fork another (child) process and implement "server" side in it, which would receive raw bytes and return encoded attributed strings, and subsequently implement "client" side in the parent process (in its secondary thread), which would send raw bytes and receive back encoded attributed strings?

This is workable, but make sure you use a fork()/exec() pair to re- execute yourself in that case, and use argc/argv in your main() to determine which mode to run in. Don't just use fork() by itself - there are severe limits to what you can do in an only-fork()ed process. What those limits are isn't entirely clear to me; perhaps someone else could elaborate on that?

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to