coreconn.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. //////////////////////////////////////////////////////////////
  3. /// \file
  4. /// \brief Definitions for asynchonous connection queue
  5. #include "base.h"
  6. #include "event_loop.h"
  7. #include "netaddr.h"
  8. #include <util/datetime/base.h>
  9. #include <util/generic/algorithm.h>
  10. #include <util/generic/list.h>
  11. #include <util/generic/map.h>
  12. #include <util/generic/set.h>
  13. #include <util/generic/string.h>
  14. #include <util/generic/vector.h>
  15. #include <util/network/address.h>
  16. #include <util/network/ip.h>
  17. #include <util/network/poller.h>
  18. #include <util/string/util.h>
  19. #include <util/system/condvar.h>
  20. #include <util/system/mutex.h>
  21. #include <util/system/thread.h>
  22. #include <util/thread/lfqueue.h>
  23. #include <deque>
  24. #include <utility>
  25. #ifdef NO_ERROR
  26. #undef NO_ERROR
  27. #endif
  28. #define BUS_WORKER_CONDVAR
  29. //#define BUS_WORKER_MIXED
  30. namespace NBus {
  31. class TBusConnection;
  32. class TBusConnectionFactory;
  33. class TBusServerFactory;
  34. using TBusConnectionList = TList<TBusConnection*>;
  35. /// @throw yexception
  36. EIpVersion MakeIpVersion(bool allowIpv4, bool allowIpv6);
  37. inline bool WouldBlock() {
  38. int syserr = LastSystemError();
  39. return syserr == EAGAIN || syserr == EINPROGRESS || syserr == EWOULDBLOCK || syserr == EINTR;
  40. }
  41. class TBusSession;
  42. struct TMaxConnectedException: public yexception {
  43. TMaxConnectedException(unsigned maxConnect) {
  44. yexception& exc = *this;
  45. exc << TStringBuf("Exceeded maximum number of outstanding connections: ");
  46. exc << maxConnect;
  47. }
  48. };
  49. enum EPollType {
  50. POLL_READ,
  51. POLL_WRITE
  52. };
  53. }