NamedEvent_VMS.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // NamedEvent_VMS.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/NamedEvent_VMS.cpp#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Processes
  8. // Module: NamedEvent
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/NamedEvent_VMS.h"
  16. #include <lib$routines.h>
  17. #include <starlet.h>
  18. #include <descrip.h>
  19. #include <iodef.h>
  20. namespace Poco {
  21. NamedEventImpl::NamedEventImpl(const std::string& name):
  22. _name(name)
  23. {
  24. struct dsc$descriptor_s mbxDesc;
  25. mbxDesc.dsc$w_length = _name.length();
  26. mbxDesc.dsc$b_dtype = DSC$K_DTYPE_T;
  27. mbxDesc.dsc$b_class = DSC$K_CLASS_S;
  28. mbxDesc.dsc$a_pointer = _name.c_str();
  29. if (sys$crembx(0, &_mbxChan, 0, 0, 0, 0, &mbxDesc, 0, 0) != 1)
  30. throw SystemException("cannot create named event", _name);
  31. }
  32. NamedEventImpl::~NamedEventImpl()
  33. {
  34. sys$dassgn(_mbxChan);
  35. }
  36. void NamedEventImpl::setImpl()
  37. {
  38. char buffer = 0xFF;
  39. if (sys$qio(0, _mbxChan, IO$_WRITEVBLK, 0, 0, 0, &buffer, sizeof(buffer), 0, 0, 0, 0) != 1)
  40. throw SystemException("cannot set named event", _name);
  41. }
  42. void NamedEventImpl::waitImpl()
  43. {
  44. char buffer = 0;
  45. while (buffer == 0)
  46. {
  47. if (sys$qiow(0, _mbxChan, IO$_READVBLK, 0, 0, 0, &buffer, sizeof(buffer), 0, 0, 0, 0) != 1)
  48. throw SystemException("cannot wait for named event", _name);
  49. }
  50. }
  51. } // namespace Poco