EventInterface.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 resource $fd
  45. * @param int $flag
  46. * @param callable $func
  47. * @return bool
  48. */
  49. public function add($fd, $flag, $func, $args = null);
  50. /**
  51. * Remove event listener from event loop.
  52. * @param resource $fd
  53. * @param int $flag
  54. * @return bool
  55. */
  56. public function del($fd, $flag);
  57. /**
  58. * Remove all timers.
  59. * @return void
  60. */
  61. public function clearAllTimer();
  62. /**
  63. * Main loop.
  64. * @return void
  65. */
  66. public function loop();
  67. }