Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

problem in MREWS.EndWrite procedure

john111smithjohn111smith Member Posts: 15
Hi,

application has developed with several hundred MREWS Write/Read blocks.
several minutes after running, assert(FWriterID = GetCurrentThreadID); raise error in MREWS.EndWrite procedure with FWriterID = 0

what is the problem?

all functions available in "Sysutils.pas"

procedure TMultiReadExclusiveWriteSynchronizer.EndWrite;
var
Thread: PThreadInfo;
begin
{$IFDEF DEBUG_MREWS}
Debug('Write end');
{$ENDIF}
assert(FWriterID = GetCurrentThreadID);
tls.Open(Thread);
Dec(FWriteRecursionCount);
if FWriteRecursionCount = 0 then
begin
FWriterID := 0; //the only line in code for zero it
InterlockedExchangeAdd(FSentinel, mrWriteRequest);
{$IFDEF DEBUG_MREWS}
Debug('Write about to UnblockOneWriter');
{$ENDIF}
UnblockOneWriter;
{$IFDEF DEBUG_MREWS}
Debug('Write about to UnblockReaders');
{$ENDIF}
UnblockReaders;
end;
if Thread.RecursionCount = 0 then
tls.Delete(Thread);
{$IFDEF DEBUG_MREWS}
Debug('Write unlock');
{$ENDIF}
end;

Sign In or Register to comment.