title: Thread pool shared resource locking problem
body: <p>I have a UDP based application that is implemented using a thread pool.</p>
  
  <p>Messages are pushed onto a queue and the thread pool is woken when there are things to do or messages on the queue. The thread pool processes each of the messages and hands them off to
  session objects which hold some state.  i.e. the UDP packets are part of a session and the session is reassembling a large block of data.</p>
  
  <p>That session object needs to access a shared resource.  However, another session object can also read from the resource, but not while it's being written to. </p>
  
  <p>Now the problem is that the session objects DoWork method can be called from different threads and I need to prevent anyone writing to it.  So to do that I need to put a lock around the resource.</p>
  
  <p>Here is where the problem arises.  If I use a standard mutex, it's not portable between threads so I will try to access the resource and should be able to put the data into the resource but I can't unless I'm the original thread that locked the resource.</p>
  
  <p>It's as thought I need a session key to gain access to the resource rather than my 
  thread id.</p>
  
  <p>How do I get around this? boost shared_mutex here seems a bit limited in this case.</p>