{--------------------------------------------------------------------------- The control program for mass-spectrometer MI1201-AGM (c) Copyright Aleksandrov O.E., 2001 Molecular Physics department, USTU, Ekaterinsburg, K-2, 620002, RUSSIA phone 75-47-15 E-mail: aleks@dpt.ustu.ru Программа управления масс-спектрометром МИ1201-АГМ (c) Собственность Александрова О.Е., 2001 620002, Екатеринбург, К-2, УГТУ, Кафедра молекулярной физики тел. 75-47-15 E-mail: aleks@dpt.ustu.ru ----------------------------------------------------------------------------} unit MultiThreadList; interface USES SysUtils, Classes, Windows; type tMultiThreadList=class(tList) protected MultiReadExclusiveWriteSynchronizer:TMultiReadExclusiveWriteSynchronizer; function Get(Index:integer):Pointer; procedure Put(Index:integer; AItem:Pointer); public procedure BeginRead; procedure EndRead; procedure BeginWrite; procedure EndWrite; constructor Create; destructor Destroy; override; procedure Sort(Compare: TListSortCompare); procedure Clear; override; function Expand: TList; procedure Pack; function Extract(Item: Pointer): Pointer; procedure Move(CurIndex, NewIndex: Integer); procedure Exchange(Index1, Index2: Integer); function Add(Item: Pointer): Integer; function Remove(Item: Pointer): Integer; procedure Delete(Index: Integer); property Items[Index: Integer]: Pointer read Get write Put; default; procedure Insert(Index: Integer; Item: Pointer); end; implementation procedure tMultiThreadList.Exchange(Index1, Index2: Integer); begin BeginWrite; try Inherited Exchange(Index1, Index2); finally EndWrite; end; end; function tMultiThreadList.Expand: TList; begin BeginWrite; try Result:=Inherited Expand; finally EndWrite; end; end; procedure tMultiThreadList.Move(CurIndex, NewIndex: Integer); begin BeginWrite; try Inherited; finally EndWrite; end; end; function tMultiThreadList.Extract(Item: Pointer): Pointer; begin BeginWrite; try Result:=Inherited Extract(Item); finally EndWrite; end; end; procedure tMultiThreadList.Pack; begin BeginWrite; try Inherited; finally EndWrite; end; end; procedure tMultiThreadList.Clear; begin BeginWrite; try Inherited; finally EndWrite; end; end; procedure tMultiThreadList.Sort(Compare: TListSortCompare); begin BeginWrite; try Inherited; finally EndWrite; end; end; procedure tMultiThreadList.BeginRead; begin MultiReadExclusiveWriteSynchronizer.BeginRead; end; procedure tMultiThreadList.EndRead; begin MultiReadExclusiveWriteSynchronizer.EndRead; end; procedure tMultiThreadList.BeginWrite; begin MultiReadExclusiveWriteSynchronizer.BeginWrite; end; procedure tMultiThreadList.EndWrite; begin MultiReadExclusiveWriteSynchronizer.EndWrite; end; constructor tMultiThreadList.Create; begin MultiReadExclusiveWriteSynchronizer:=TMultiReadExclusiveWriteSynchronizer.Create; MultiReadExclusiveWriteSynchronizer.BeginWrite; try Inherited; finally MultiReadExclusiveWriteSynchronizer.EndWrite; end; end; destructor tMultiThreadList.Destroy; begin MultiReadExclusiveWriteSynchronizer.BeginWrite; try Inherited Destroy; finally // MultiReadExclusiveWriteSynchronizer.EndWrite; MultiReadExclusiveWriteSynchronizer.Free; end; end; function tMultiThreadList.Add(Item:Pointer):integer; begin MultiReadExclusiveWriteSynchronizer.BeginWrite; try Result:=Inherited Add(Item); finally MultiReadExclusiveWriteSynchronizer.EndWrite; end; end; function tMultiThreadList.Remove(Item:Pointer):integer; begin MultiReadExclusiveWriteSynchronizer.BeginWrite; try Result:=Inherited Remove(Item); finally MultiReadExclusiveWriteSynchronizer.EndWrite; end; end; procedure tMultiThreadList.Delete(Index: Integer); begin MultiReadExclusiveWriteSynchronizer.BeginWrite; try Inherited Delete(Index); finally MultiReadExclusiveWriteSynchronizer.EndWrite; end; end; function tMultiThreadList.Get(Index:integer):pointer; begin MultiReadExclusiveWriteSynchronizer.BeginRead; try Result:=inherited Get(Index); finally MultiReadExclusiveWriteSynchronizer.EndRead; end; end; procedure tMultiThreadList.Put(Index:integer; AItem:Pointer); begin MultiReadExclusiveWriteSynchronizer.BeginWrite; try inherited Put(Index,AItem); finally MultiReadExclusiveWriteSynchronizer.EndWrite; end; end; procedure tMultiThreadList.Insert(Index: Integer; Item: Pointer); begin MultiReadExclusiveWriteSynchronizer.BeginWrite; try inherited Insert(Index,Item); finally MultiReadExclusiveWriteSynchronizer.EndWrite; end; end; end.