Board index » cppbuilder » Has anyone used TMultiReadExclusiveWriteSynchronizer?
Fred Hebert
CBuilder Developer |
Has anyone used TMultiReadExclusiveWriteSynchronizer?2005-01-28 07:03:45 AM cppbuilder90 I am writing a DLL that uses a thread to do socket communications with an automation controller. There is only one DLL, and one thread. Everything is working fine, but I am trying to add a user abort function. Basically I have a variable in the thread called UserAbort. The functions that do the communications check the state of this variable frequently to see if they should abort. The thread reads the variable frequently, but only writes to it in the constructor, and after it has performed the user abort to reset it to false. I was trying to decide the best way to set this variable from the DLL, and was considering TMultiReadExclusiveWriteSynchronizer? Any suggestions? Pseudo code fragment: Thread: while (!Done && !UserAbort) WorkVeryHard; if (UserAbort) UserAbort = false; // reset DLL: void SendUserAbort(void) { if ((MyThread != NULL) && (!MyThread->Suspended)) // must exist and be busy { MyThread->UserAbort = true; } } (No one panic...) Do you think I could even get away without locking at all? |