doc_anonymous_semaphore_shared_data.hpp 845 B

12345678910111213141516171819202122232425262728
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //[doc_anonymous_semaphore_shared_data
  11. #include <boost/interprocess/sync/interprocess_semaphore.hpp>
  12. struct shared_memory_buffer
  13. {
  14. enum { NumItems = 10 };
  15. shared_memory_buffer()
  16. : mutex(1), nempty(NumItems), nstored(0)
  17. {}
  18. //Semaphores to protect and synchronize access
  19. boost::interprocess::interprocess_semaphore
  20. mutex, nempty, nstored;
  21. //Items to fill
  22. int items[NumItems];
  23. };
  24. //]