EventInterface.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * Signal event.
  31. *
  32. * @var int
  33. */
  34. const EV_SIGNAL = 4;
  35. /**
  36. * Timer event.
  37. *
  38. * @var int
  39. */
  40. const EV_TIMER = 8;
  41. /**
  42. * Timer once event.
  43. *
  44. * @var int
  45. */
  46. const EV_TIMER_ONCE = 16;
  47. /**
  48. * Add event listener to event loop.
  49. *
  50. * @param mixed $fd
  51. * @param int $flag
  52. * @param callable $func
  53. * @param mixed $args
  54. * @return bool
  55. */
  56. public function add($fd, $flag, $func, $args = null);
  57. /**
  58. * Remove event listener from event loop.
  59. *
  60. * @param mixed $fd
  61. * @param int $flag
  62. * @return bool
  63. */
  64. public function del($fd, $flag);
  65. /**
  66. * Remove all timers.
  67. *
  68. * @return void
  69. */
  70. public function clearAllTimer();
  71. /**
  72. * Main loop.
  73. *
  74. * @return void
  75. */
  76. public function loop();
  77. }