RWLock_VX.cpp 977 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // RWLock_VX.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/RWLock_VX.cpp#2 $
  5. //
  6. // Library: Foundation
  7. // Package: Threading
  8. // Module: RWLock
  9. //
  10. // Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/RWLock_VX.h"
  16. #include <cstring>
  17. namespace Poco {
  18. RWLockImpl::RWLockImpl()
  19. {
  20. #if defined(POCO_VXWORKS)
  21. // This workaround is for VxWorks 5.x where
  22. // pthread_mutex_init() won't properly initialize the mutex
  23. // resulting in a subsequent freeze in pthread_mutex_destroy()
  24. // if the mutex has never been used.
  25. std::memset(&_mutex, 0, sizeof(_mutex));
  26. #endif
  27. pthread_mutexattr_t attr;
  28. pthread_mutexattr_init(&attr);
  29. if (pthread_mutex_init(&_mutex, &attr))
  30. {
  31. pthread_mutexattr_destroy(&attr);
  32. throw SystemException("cannot create mutex");
  33. }
  34. pthread_mutexattr_destroy(&attr);
  35. }
  36. RWLockImpl::~RWLockImpl()
  37. {
  38. pthread_mutex_destroy(&_mutex);
  39. }
  40. } // namespace Poco