How can I implement a thread-safe list wrapper in Delphi?

I have a list wrapper that maintains two Tstringlists and a TClassList

I need this to be thread safe, such that:

  • Concurrent writes are not allowed (wait state of some sort should be entered)
  • Reading while writing (or vice versa) is not allowed (wait state of some sort should be entered)
  • Concurrent reads are allowed

Any ideas on how I can do this? My instinct tells me it needs more than just a critical section, perhaps a semaphore or "usage counter", perhaps one of these in conjunction with a CS.

I'm just not quite sure where to start - anything from an overall approach in english to psuedo-code, to delphi implementation or external link would be much appreciated.

Answers


You should have a look at the TMultiReadExclusiveWriteSynchronizer class declared in sysutils.pas...


Need Your Help

Show-Hide divs using jquery in a dropdown with a twist

jquery html drop-down-menu show-hide

I want to show/hide elements depending on what is selected in the dropdown menu, I got it, but I want divs to show when either DIVAREA2 or DIVAREA3 is selected. Say, I want DIV area 4 to show in Di...

Angular $watch on an array of objects

javascript arrays angularjs object

Lets say i have an array of animal objects bound to my scope. Each object has a 'name' property and a 'sound' property.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.