當前位置: 首頁>>代碼示例>>Golang>>正文


Golang syscall.UnmapViewOfFile函數代碼示例

本文整理匯總了Golang中syscall.UnmapViewOfFile函數的典型用法代碼示例。如果您正苦於以下問題:Golang UnmapViewOfFile函數的具體用法?Golang UnmapViewOfFile怎麽用?Golang UnmapViewOfFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了UnmapViewOfFile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: munmap

func munmap(b []byte) (err error) {
	m := MMap(b)
	dh := m.header()

	addr := dh.Data
	length := uintptr(dh.Len)

	flush(addr, length)
	err = syscall.UnmapViewOfFile(addr)
	if err != nil {
		return err
	}

	handleLock.Lock()
	defer handleLock.Unlock()
	handle, ok := handleMap[addr]
	if !ok {
		// should be impossible; we would've errored above
		return errors.New("unknown base address")
	}
	delete(handleMap, addr)

	e := syscall.CloseHandle(syscall.Handle(handle))
	return os.NewSyscallError("CloseHandle", e)
}
開發者ID:shirkevich,項目名稱:goffee,代碼行數:25,代碼來源:reader_windows.go

示例2: munmap

// munmap Windows implementation
// Based on: https://github.com/edsrzf/mmap-go
// Based on: https://github.com/boltdb/bolt/bolt_windows.go
func munmap(b []byte) (err error) {
	handleLock.Lock()
	defer handleLock.Unlock()

	addr := (uintptr)(unsafe.Pointer(&b[0]))
	if err := syscall.UnmapViewOfFile(addr); err != nil {
		return os.NewSyscallError("UnmapViewOfFile", err)
	}

	handle, ok := handleMap[addr]
	if !ok {
		// should be impossible; we would've seen the error above
		return errors.New("unknown base address")
	}
	delete(handleMap, addr)

	e := syscall.CloseHandle(syscall.Handle(handle))
	if e != nil {
		return os.NewSyscallError("CloseHandle", e)
	}

	file, ok := fileMap[addr]
	if !ok {
		// should be impossible; we would've seen the error above
		return errors.New("unknown base address")
	}
	delete(fileMap, addr)

	e = file.Close()
	if e != nil {
		return errors.New("close file" + e.Error())
	}
	return nil
}
開發者ID:ChenXiukun,項目名稱:influxdb,代碼行數:37,代碼來源:mmap_windows.go

示例3: unmmapFile

func unmmapFile(m *mmapData) error {
	err := syscall.UnmapViewOfFile(uintptr(unsafe.Pointer(&m.d[0])))
	if err != nil {
		return err
	}

	return m.f.Close()
}
開發者ID:Rajat-Agrawal,項目名稱:hound,代碼行數:8,代碼來源:mmap_windows.go

示例4: unmap

func (m *mmap) unmap() error {
	slcHead := (*reflect.SliceHeader)(unsafe.Pointer(&m.buf))
	err := syscall.UnmapViewOfFile(slcHead.Data)
	if err != nil {
		return err
	}
	return os.NewSyscallError("CloseHandle", syscall.CloseHandle(syscall.Handle(m.handle)))
}
開發者ID:ross-spencer,項目名稱:siegfried,代碼行數:8,代碼來源:mmap_windows.go

示例5: munmap

// munmap unmaps a pointer from a file.
// Based on: https://github.com/edsrzf/mmap-go
func munmap(db *DB) error {
	if db.data == nil {
		return nil
	}

	addr := (uintptr)(unsafe.Pointer(&db.data[0]))
	if err := syscall.UnmapViewOfFile(addr); err != nil {
		return os.NewSyscallError("UnmapViewOfFile", err)
	}
	return nil
}
開發者ID:XuHuaiyu,項目名稱:tidb,代碼行數:13,代碼來源:bolt_windows.go

示例6: unmap

func unmap(addr, len uintptr) error {
	if err := syscall.UnmapViewOfFile(addr); err != nil {
		return err
	}

	handleLock.Lock()
	defer handleLock.Unlock()
	handle := handleMap[addr]
	delete(handleMap, addr)

	return os.NewSyscallError("CloseHandle", syscall.CloseHandle(syscall.Handle(handle)))
}
開發者ID:Lanzafame,項目名稱:tiedot,代碼行數:12,代碼來源:mmap_windows.go

示例7: unmmapFile

func unmmapFile(mm *mmapData) {
	err := syscall.UnmapViewOfFile(uintptr(unsafe.Pointer(&mm.d[0])))
	if err != nil {
		log.Fatal(err)
	}
	err2 := syscall.CloseHandle(syscall.Handle(mm.h))
	if err2 != nil {
		log.Fatal(err2)
	}
	err3 := mm.f.Close()
	if err3 != nil {
		log.Fatal(err3)
	}
}
開發者ID:pmezard,項目名稱:codesearch,代碼行數:14,代碼來源:mmap_windows.go

示例8: Close

// Close closes the reader.
func (r *ReaderAt) Close() error {
	if r.data == nil {
		return nil
	}
	data := r.data
	r.data = nil
	if debug {
		var p *byte
		if len(data) != 0 {
			p = &data[0]
		}
		println("munmap", r, p)
	}
	runtime.SetFinalizer(r, nil)
	return syscall.UnmapViewOfFile(uintptr(unsafe.Pointer(&data[0])))
}
開發者ID:dylanpoe,項目名稱:golang.org,代碼行數:17,代碼來源:mmap_windows.go

示例9: unmap

func unmap(addr, len uintptr) error {
	flush(addr, len)
	err := syscall.UnmapViewOfFile(addr)
	if err != nil {
		return err
	}

	handleLock.Lock()
	defer handleLock.Unlock()
	handle, ok := handleMap[addr]
	if !ok {
		// should be impossible; we would've errored above
		return errors.New("unknown base address")
	}
	delete(handleMap, addr)

	e := syscall.CloseHandle(syscall.Handle(handle))
	return os.NewSyscallError("CloseHandle", e)
}
開發者ID:huanshi,項目名稱:tiedot,代碼行數:19,代碼來源:mmap_windows.go

示例10: unmap

func unmap(addr, len uintptr) os.Error {
	flush(addr, len)
	errno := syscall.UnmapViewOfFile(addr)
	if errno != 0 {
		return os.NewSyscallError("UnmapViewOfFile", errno)
	}

	handleLock.Lock()
	defer handleLock.Unlock()
	handle, ok := handleMap[addr]
	if !ok {
		// should be impossible; we would've errored above
		return os.NewError("unknown base address")
	}
	handleMap[addr] = 0, false

	e := syscall.CloseHandle(handle)
	return os.NewSyscallError("CloseHandle", e)
}
開發者ID:slyphon,項目名稱:mmap-go,代碼行數:19,代碼來源:mmap_windows.go

示例11: unmap

func unmap(p []byte) error {
	addr := uintptr(unsafe.Pointer(&p[0]))
	syscall.FlushViewOfFile(addr, uintptr(len(p)))
	err := syscall.UnmapViewOfFile(addr)
	if err != nil {
		return err
	}

	handleLock.Lock()
	defer handleLock.Unlock()
	handle, ok := handleMap[addr]
	if !ok {
		// should be impossible; we would've errored above
		return errors.New("unknown base address")
	}
	delete(handleMap, addr)

	e := syscall.CloseHandle(syscall.Handle(handle))
	return os.NewSyscallError("CloseHandle", e)
}
開發者ID:Joinhack,項目名稱:fqueue,代碼行數:20,代碼來源:mmap_windows.go

示例12: unmap_file

// Implement munmap for windows
func unmap_file(data []byte) error {

	// Use unsafe to get the buffer address
	addr := uintptr(unsafe.Pointer(&data[0]))

	// retrieve the mapping handle
	win_mapper_mutex.Lock()
	h := win_mapper_handle[addr]
	delete(win_mapper_handle, addr)
	win_mapper_mutex.Unlock()

	// unmap file view
	err := syscall.UnmapViewOfFile(addr)

	// close the mapping handle
	if err == nil {
		err = syscall.CloseHandle(h)
	}

	return err
}
開發者ID:spcau,項目名稱:godiff,代碼行數:22,代碼來源:godiff_windows.go

示例13: unmap

func unmap(addr, len uintptr) error {
	flush(addr, len)
	// Lock the UnmapViewOfFile along with the handleMap deletion.
	// As soon as we unmap the view, the OS is free to give the
	// same addr to another new map. We don't want another goroutine
	// to insert and remove the same addr into handleMap while
	// we're trying to remove our old addr/handle pair.
	handleLock.Lock()
	defer handleLock.Unlock()
	err := syscall.UnmapViewOfFile(addr)
	if err != nil {
		return err
	}

	handle, ok := handleMap[addr]
	if !ok {
		// should be impossible; we would've errored above
		return errors.New("unknown base address")
	}
	delete(handleMap, addr)

	e := syscall.CloseHandle(syscall.Handle(handle))
	return os.NewSyscallError("CloseHandle", e)
}
開發者ID:CaptainIlu,項目名稱:cloud-torrent,代碼行數:24,代碼來源:mmap_windows.go

示例14: Close

func (agent Pagent) Close() {
	defer syscall.CloseHandle(agent.Hwnd)
	defer syscall.CloseHandle(agent.Fmap)
	defer syscall.UnmapViewOfFile(agent.SharedMemory)

}
開發者ID:tbaehler,項目名稱:ssh_proxy,代碼行數:6,代碼來源:pgutil.go

示例15: destroy

func (m *Mapping) destroy() {
	syscall.UnmapViewOfFile(m.addr)
	syscall.CloseHandle(m.mapping)
}
開發者ID:sjn1978,項目名稱:go-fuzz,代碼行數:4,代碼來源:sys_windows.go


注:本文中的syscall.UnmapViewOfFile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。