예제 #1
0
파일: buffer.go 프로젝트: postfix/buffer
func (b *Buffer) dontNeed(i, j uint64) error {
	// Since i is rounded up to the nearest multiple of
	// pageSize before the call, i > j is not an error.
	if i > j {
		return nil
	}
	return syscall.Madvise(b.data[i:j], syscall.MADV_DONTNEED)
}
예제 #2
0
파일: shm_linux.go 프로젝트: jsgilmore/shm
func (buf *sharedBuffer) Advise(offset, length, advice int) error {
	b := buf.Bytes()
	err := checkOffsetLength(b, offset, length)
	if err == nil {
		err = syscall.Madvise(b[offset:offset+length], advice)
	}
	return os.NewSyscallError("shm: madvise", err)
}
예제 #3
0
func adviseRead(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL|syscall.MADV_WILLNEED)
}
예제 #4
0
func adviseWrite(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL)
}
예제 #5
0
// Give kernel hints about usage pattern.
func (m Mmap) Advise(advice Advice) error {
	return syscall.Madvise(m, int(advice))
}