ZmqContext.cpp 725 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Author:
  3. * Sven Czarnian <devel@svcz.de>
  4. * Brief:
  5. * Implements the zmq context manager
  6. * Copyright:
  7. * 2021 Sven Czarnian
  8. * License:
  9. * GNU General Public License v3 (GPLv3)
  10. */
  11. #include "ZmqContext.h"
  12. using namespace aman;
  13. ZmqContext::ZmqContext() : m_context() { }
  14. void ZmqContext::initialize() {
  15. if (nullptr == this->m_context)
  16. this->m_context = std::make_unique<zmq::context_t>(2);
  17. }
  18. void ZmqContext::deinitialize() {
  19. if (nullptr != this->m_context)
  20. this->m_context = std::unique_ptr<zmq::context_t>();
  21. }
  22. zmq::context_t& ZmqContext::context() {
  23. return *this->m_context;
  24. }
  25. ZmqContext& ZmqContext::instance() {
  26. static ZmqContext __instance;
  27. return __instance;
  28. }