EventInterface.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. * @var int
  20. */
  21. const EV_READ = 1;
  22. /**
  23. * Write event.
  24. * @var int
  25. */
  26. const EV_WRITE = 2;
  27. /**
  28. * Signal event.
  29. * @var int
  30. */
  31. const EV_SIGNAL = 4;
  32. /**
  33. * Timer event.
  34. * @var int
  35. */
  36. const EV_TIMER = 8;
  37. /**
  38. * Timer once event.
  39. * @var int
  40. */
  41. const EV_TIMER_ONCE = 16;
  42. /**
  43. * Add event listener to event loop.
  44. * @param mixed $fd
  45. * @param int $flag
  46. * @param callable $func
  47. * @param mixed $args
  48. * @return bool
  49. */
  50. public function add($fd, $flag, $func, $args = null);
  51. /**
  52. * Remove event listener from event loop.
  53. * @param mixed $fd
  54. * @param int $flag
  55. * @return bool
  56. */
  57. public function del($fd, $flag);
  58. /**
  59. * Remove all timers.
  60. * @return void
  61. */
  62. public function clearAllTimer();
  63. /**
  64. * Main loop.
  65. * @return void
  66. */
  67. public function loop();
  68. }