EventInterface.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. * Delay the execution of a callback.
  19. * @param float $delay
  20. * @param $func
  21. * @param $args
  22. * @return int|bool
  23. */
  24. public function delay(float $delay, $func, $args);
  25. /**
  26. * Repeatedly execute a callback.
  27. * @param float $interval
  28. * @param $func
  29. * @param $args
  30. * @return int|bool
  31. */
  32. public function repeat(float $interval, $func, $args);
  33. /**
  34. * Delete a timer.
  35. * @param $timer_id
  36. * @return bool
  37. */
  38. public function deleteTimer($timer_id);
  39. /**
  40. * Execute a callback when a stream resource becomes readable or is closed for reading.
  41. * @param $stream
  42. * @param $func
  43. * @return void
  44. */
  45. public function onReadable($stream, $func);
  46. /**
  47. * Cancel a callback of stream readable.
  48. * @param $stream
  49. * @return void
  50. */
  51. public function offReadable($stream);
  52. /**
  53. * Execute a callback when a stream resource becomes writable or is closed for writing.
  54. * @param $stream
  55. * @param $func
  56. * @return void
  57. */
  58. public function onWritable($stream, $func);
  59. /**
  60. * Cancel a callback of stream writable.
  61. * @param $stream
  62. * @return mixed
  63. */
  64. public function offWritable($stream);
  65. /**
  66. * Execute a callback when a signal is received.
  67. * @param $signal
  68. * @param $func
  69. * @return void
  70. */
  71. public function onSignal($signal, $func);
  72. /**
  73. * Cancel a callback of signal.
  74. * @param $signal
  75. * @return void
  76. */
  77. public function offSignal($signal);
  78. /**
  79. * Delete all timer.
  80. * @return void
  81. */
  82. public function deleteAllTimer();
  83. /**
  84. * Run the event loop.
  85. * @return void
  86. */
  87. public function run();
  88. /**
  89. * Stop event loop.
  90. * @return void
  91. */
  92. public function stop();
  93. /**
  94. *
  95. * @return int
  96. */
  97. public function getTimerCount();
  98. }