当前位置: 首页>>代码示例>>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;未经允许,请勿转载。