EventInterface.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * This file is part of workerman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<walkor@workerman.net>
  10. * @copyright walkor<walkor@workerman.net>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Workerman\Events;
  15. interface EventInterface
  16. {
  17. /**
  18. * Read event.
  19. *
  20. * @var int
  21. */
  22. const EV_READ = 1;
  23. /**
  24. * Write event.
  25. *
  26. * @var int
  27. */
  28. const EV_WRITE = 2;
  29. /**
  30. * Except event
  31. *
  32. * @var int
  33. */
  34. const EV_EXCEPT = 3;
  35. /**
  36. * Signal event.
  37. *
  38. * @var int
  39. */
  40. const EV_SIGNAL = 4;
  41. /**
  42. * Timer event.
  43. *
  44. * @var int
  45. */
  46. const EV_TIMER = 8;
  47. /**
  48. * Timer once event.
  49. *
  50. * @var int
  51. */
  52. const EV_TIMER_ONCE = 16;
  53. /**
  54. * Add event listener to event loop.
  55. *
  56. * @param mixed $fd
  57. * @param int $flag
  58. * @param callable $func
  59. * @param mixed $args
  60. * @return bool
  61. */
  62. public function add($fd, $flag, $func, $args = null);
  63. /**
  64. * Remove event listener from event loop.
  65. *
  66. * @param mixed $fd
  67. * @param int $flag
  68. * @return bool
  69. */
  70. public function del($fd, $flag);
  71. /**
  72. * Remove all timers.
  73. *
  74. * @return void
  75. */
  76. public function clearAllTimer();
  77. /**
  78. * Main loop.
  79. *
  80. * @return void
  81. */
  82. public function loop();
  83. /**
  84. * Destroy loop.
  85. *
  86. * @return mixed
  87. */
  88. public function destroy();
  89. /**
  90. * Get Timer count.
  91. *
  92. * @return mixed
  93. */
  94. public function getTimerCount();
  95. }