nibs and processes

theed

Registered
Hi, this may better belong somewhere else, but I like it here, so I thought I'd ask here first:

I am accessing the standard preferences file, which is documented to not be thread safe. So I want to keep all access to the prefs going through one process, so that it can't possibly try to access a second item in the middle of accessing the first. ... sooooooo

I have a number of different nib files that all need access to various prefs. Is it enough to keep one instance of one class in one nib in charge of the prefs file, taking requests from any other nib / object? Will this make sure that 2 prefs aren't asked for at the exact same time?

IE, is it reasonable to think of one thread per nib, and that no other threads are going to try to execute that nib's code? I'm in java, and I know java daes aggressive inlining of everything, but it shouldn't violate this.

Hell, I'll take guesses if you guys don't have real answers. :)
 
ok, first of all, i don't know how unorthodox this is, i'll write it anyway. if i'm completely wrong here or if i suggest stuff that will immediately cause apocalypse, flame me ;)

if it's just about accessing the prefs and not about doing gui stuff, i'd simply use a lock. that simple.
 
I'm not sure if that gets me any further. In order to properly use a lock, I need to know pretty much the same things. What's a thread and what's not. I should just read same more developer docs. It's probably in there somewhere.

I considered locking with file writing, but boy is that a hack. I also considered copying the prefs into my own object that wouldn't have concurrency issues. But that's all dumb. There's this beautiful preferences handling mechanism that's very automatic and clean, and Apple keeps it up to date. I just really need to know how to properly use that.
 
Back
Top