1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Timer: Refine the hour glass, support stop

This commit is contained in:
winlin 2021-02-09 11:54:08 +08:00
parent 45834b805b
commit 98c29a1494
2 changed files with 11 additions and 5 deletions

View file

@ -65,6 +65,11 @@ srs_error_t SrsHourGlass::start()
return err; return err;
} }
void SrsHourGlass::stop()
{
trd->stop();
}
srs_error_t SrsHourGlass::tick(srs_utime_t interval) srs_error_t SrsHourGlass::tick(srs_utime_t interval)
{ {
return tick(0, interval); return tick(0, interval);

View file

@ -60,11 +60,11 @@ public:
// It's a complex and high-performance timer. // It's a complex and high-performance timer.
// //
// Usage: // Usage:
// SrsHourGlass* hg = new SrsHourGlass(handler, 1 * SRS_UTIME_MILLISECONDS); // SrsHourGlass* hg = new SrsHourGlass(handler, 100 * SRS_UTIME_MILLISECONDS);
// //
// hg->tick(1, 3 * SRS_UTIME_MILLISECONDS); // hg->tick(1, 300 * SRS_UTIME_MILLISECONDS);
// hg->tick(2, 5 * SRS_UTIME_MILLISECONDS); // hg->tick(2, 500 * SRS_UTIME_MILLISECONDS);
// hg->tick(3, 7 * SRS_UTIME_MILLISECONDS); // hg->tick(3, 700 * SRS_UTIME_MILLISECONDS);
// //
// // The hg will create a thread for timer. // // The hg will create a thread for timer.
// hg->start(); // hg->start();
@ -86,8 +86,9 @@ public:
SrsHourGlass(std::string label, ISrsHourGlass* h, srs_utime_t resolution); SrsHourGlass(std::string label, ISrsHourGlass* h, srs_utime_t resolution);
virtual ~SrsHourGlass(); virtual ~SrsHourGlass();
public: public:
// Start the hourglass. // Start or stop the hourglass.
virtual srs_error_t start(); virtual srs_error_t start();
virtual void stop();
public: public:
// Add a pair of tick(event, interval). // Add a pair of tick(event, interval).
// @param event the event of tick, default is 0. // @param event the event of tick, default is 0.