From a0071a7f7dabbbd58f774435654765c3fb524c6c Mon Sep 17 00:00:00 2001 From: Nan Deng Date: Thu, 19 Jun 2014 14:48:21 -0700 Subject: [PATCH] comment. --- storage/memory/memory.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/storage/memory/memory.go b/storage/memory/memory.go index 539dbcd3..63c6d552 100644 --- a/storage/memory/memory.go +++ b/storage/memory/memory.go @@ -95,6 +95,16 @@ func (self *containerStorage) RecentStats(numStats int) ([]*info.ContainerStats, if self.recentStats.Len() < numStats || numStats < 0 { numStats = self.recentStats.Len() } + + // Stats in the recentStats list are stored in reverse chronological + // order, i.e. most recent stats is in the front. + // numStats will always <= recentStats.Len() so that there will be + // always at least numStats available stats to retrieve. We traverse + // the recentStats list from its head and fill the ret slice in + // reverse order so that the returned slice will be in chronological + // order. The order of the returned slice is not specified by the + // StorageDriver interface, so it is not necessary for other storage + // drivers to return the slice in the same order. ret := make([]*info.ContainerStats, numStats) e := self.recentStats.Front() for i := numStats - 1; i >= 0; i-- {