INetMQPoller.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. namespace NetMQ
  3. {
  4. /// <summary>
  5. /// Interface to of the NetMQPoller, implement to fake the NetMQPoller in tests.
  6. /// </summary>
  7. public interface INetMQPoller : IDisposable
  8. {
  9. /// <summary>
  10. /// Runs the poller on the caller's thread. Only returns when <see cref="Stop"/> or <see cref="StopAsync"/> are called from another thread.
  11. /// </summary>
  12. void Run();
  13. /// <summary>
  14. /// Runs the poller in a background thread, returning once the poller has started.
  15. /// </summary>
  16. void RunAsync();
  17. /// <summary>
  18. /// Stops the poller.
  19. /// </summary>
  20. /// <remarks>
  21. /// If called from a thread other than the poller thread, this method will block until the poller has stopped.
  22. /// If called from the poller thread it is not possible to block.
  23. /// </remarks>
  24. void Stop();
  25. /// <summary>
  26. /// Stops the poller, returning immediately and most likely before the poller has actually stopped.
  27. /// </summary>
  28. void StopAsync();
  29. /// <summary>
  30. /// Get whether this object is currently polling its sockets and timers.
  31. /// </summary>
  32. bool IsRunning { get; }
  33. /// <summary>
  34. /// Add a socket to the poller
  35. /// </summary>
  36. /// <param name="socket">Socket to add to the poller</param>
  37. void Add(ISocketPollable socket);
  38. /// <summary>
  39. /// Remove a socket from the poller
  40. /// </summary>
  41. /// <param name="socket">The socket to be removed</param>
  42. void Remove(ISocketPollable socket);
  43. /// <summary>
  44. /// Remove the socket from the poller and dispose the socket
  45. /// </summary>
  46. /// <param name="socket">The socket to be removed</param>
  47. void RemoveAndDispose<T>(T socket) where T : ISocketPollable, IDisposable;
  48. }
  49. }