The implementation of my multithreaded data class, descendant of this, would be for example like this: Of course, I only access the parameters within the critical section. In the code above, the most intuitive in these cases would be to use the field pointer, but as "var" parameters internally it is already passed as a pointer (regardless of type), so both implementations should work in the same theoretical way (correct me if i'm wrong). SetSafeValue ( var AField : string const AValue : string ) begin BeginUpdate // Enter critical section try if AField AValue then begin AField := AValue Change end finally EndUpdate // Leave critical section triggering change event end end GetSafeValue ( var AField : string ): string begin Lock // Enter critical section try Result := AField finally Unlock // Leave critical section end end I made an implementation to reduce thousands of lines of code, which theoretically should work, but even with some successful tests, I am afraid to release a version to the end user without being sure.įunction TipCustomData. I have a base data class that is used for multithreaded data classess in my project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |