EventInterface.php 1.4 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. * 读事件
  19. * @var int
  20. */
  21. const EV_READ = 1;
  22. /**
  23. * 写事件
  24. * @var int
  25. */
  26. const EV_WRITE = 2;
  27. /**
  28. * 信号事件
  29. * @var int
  30. */
  31. const EV_SIGNAL = 4;
  32. /**
  33. * 连续的定时事件
  34. * @var int
  35. */
  36. const EV_TIMER = 8;
  37. /**
  38. * 定时一次
  39. * @var int
  40. */
  41. const EV_TIMER_ONCE = 16;
  42. /**
  43. * 添加事件回调
  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. * 删除事件回调
  52. * @param resource $fd
  53. * @param int $flag
  54. * @return bool
  55. */
  56. public function del($fd, $flag);
  57. /**
  58. * 清除所有定时器
  59. * @return void
  60. */
  61. public function clearAllTimer();
  62. /**
  63. * 事件循环
  64. * @return void
  65. */
  66. public function loop();
  67. }