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 4a37fe30c7
commit f9bd84109b
2 changed files with 11 additions and 5 deletions

View file

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

View file

@ -59,11 +59,11 @@ public:
// It's a complex and high-performance timer.
//
// 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(2, 5 * SRS_UTIME_MILLISECONDS);
// hg->tick(3, 7 * SRS_UTIME_MILLISECONDS);
// hg->tick(1, 300 * SRS_UTIME_MILLISECONDS);
// hg->tick(2, 500 * SRS_UTIME_MILLISECONDS);
// hg->tick(3, 700 * SRS_UTIME_MILLISECONDS);
//
// // The hg will create a thread for timer.
// hg->start();
@ -84,8 +84,9 @@ public:
SrsHourGlass(ISrsHourGlass* h, srs_utime_t resolution);
virtual ~SrsHourGlass();
public:
// Start the hourglass.
// Start or stop the hourglass.
virtual srs_error_t start();
virtual void stop();
public:
// Add a pair of tick(event, interval).
// @param event the event of tick, default is 0.