Brief analysis of delay queue in LIVE555

Source: Internet
Author: User

Http://www.cnblogs.com/nightwatcher/archive/2011/04/10/2011158.html

Recently looking at the source of LIVE555, feel the delay of the queue to write a good, so summed up a bit.
First, describe the design concept of the delay queue in LIVE555. First, for example, A,b,c is the three event points on the timeline, and head represents the current point in time.

If we want to describe the time when an event occurs, there are two ways: one that directly describes the absolute time the event occurred, and one that can describe the relative time that the other event occurred. The latter is used in LIVE555. In LIVE555, all event points are sorted first by the occurrence time, and then each event corresponds to a time difference from the previous event. For example, the time stored in the B event is the time required to trigger the B event after the A event is triggered. So, every time we go to query the queue for events to be triggered, we just need to query the entire queue for the first event.
Then there is the implementation in LIVE555. The entire delay queue is implemented using the Delayqueue class, and its base class Delayqueueentry is used to describe each event node. The main members in Delayqueueentry are the following: Fdelaytimeremaining represents the time difference from the previous event; Fnext and Fprev are pointers to the next and previous events on the timeline ; Ftoken represents the identity of the current node; Handletimeout is the processing method after the event times out.
And the Delayqueue class describes the specific implementation method. The first is some basic operations on this queue: the AddEntry implements the addition of an event node in the queue, RemoveEntry implements the deletion of an event node in the queue, and Updateentry implements the trigger time to update an event. While Findentrybytoken is looking for the corresponding event based on the node's identity. The most common method in this class should be synchronize, which is to synchronize the entire event queue with the current system time, detect if any events have been triggered, and if the Handlealarm method is triggered and called to process the corresponding event. And the attribute Flastsynctime represents the last synchronization of the system time, in fact, in general, the method synchronize implementation method is simply the first event node on the queue to store the difference between the current system time and the last synchronization time difference.
The basic method of implementation should be that, if you are interested in this delay queue, you can read the source code of LIVE555.

Brief analysis of delay queue in LIVE555

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.