Add comments to ethsh.go to clarify mmp package usage.

This commit is contained in:
bluewebgeek 2018-06-13 15:50:34 +08:00
parent 0ad32d3be7
commit 378d314b25

View file

@ -64,6 +64,7 @@ func isLittleEndian() bool {
} }
// memoryMap tries to memory map a file of uint32s for read only access. // memoryMap tries to memory map a file of uint32s for read only access.
// mmap is a portable memory map package which would enable direct access for memory mapping files
func memoryMap(path string) (*os.File, mmap.MMap, []uint32, error) { func memoryMap(path string) (*os.File, mmap.MMap, []uint32, error) {
file, err := os.OpenFile(path, os.O_RDONLY, 0644) file, err := os.OpenFile(path, os.O_RDONLY, 0644)
if err != nil { if err != nil {
@ -346,7 +347,8 @@ func (d *dataset) generate(dir string, limit int, test bool) {
}) })
} }
// finalizer closes any file handlers and memory maps open. // finalizer closes any file handlers and use Unmap() to deletes the memory mapped region,
// flushes any remaining changes.
func (d *dataset) finalizer() { func (d *dataset) finalizer() {
if d.mmap != nil { if d.mmap != nil {
d.mmap.Unmap() d.mmap.Unmap()