Locking from within an enumerator
Locking from within an enumerator
- Subject: Locking from within an enumerator
- From: "Mike R. Manzano" <email@hidden>
- Date: Tue, 20 Apr 2004 16:30:04 -0700
I have a data model that can be accessed by multiple threads at once.
It is basically an array of stuff. I want to be able to allow threads
to iterate over the data model, and so I was thinking of creating an
NSEnumerator subclass that locks the model for the duration of the
enumerator's life. The problem with this is that I don't know when the
NSEnumerator will have its dealloc called (actually, I don't even know
if dealloc is really ever called - I put NSLogs in - (void) dealloc
before, but the NSLogs never print out).
Anyway, back to the main point, assuming dealloc is eventually called,
I'm not sure if I can depend on that behavior to call unlock for me.
Does anyone have a better obj-c design pattern for iterating over an
array in a multithreaded environment?
Mike
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.