search for: implclose

Displaying 3 results from an estimated 3 matches for "implclose".

Did you mean: imap_close
2020 Apr 21
0
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...id := connectionID++ connectionMap[id] = h return unsafe.Pointer(uintptr(id)) } func getConn(handle unsafe.Pointer) PluginConnectionInterface { id := uint(uintptr(handle)) conn, ok = connectionMap[id] if !ok { panic("Connection %d was not open", id) } } //export implClose func implClose(handle unsafe.Pointer) { conn := getConn(handle) conn.Close() delete(connectionMap, id) } //export implGetSize func implGetSize(handle unsafe.Pointer) C.int64_t { conn := getConn(handle) size, err := conn.GetSize() if err != nil { set_error(err)...
2020 Apr 21
2
[PATCH nbdkit v2] Add the ability to write plugins in golang.
...ly C.int) unsafe.Pointer { + readonly := false + if c_readonly != 0 { + readonly = true + } + h, err := pluginImpl.Open(readonly) + if err != nil { + set_error(err) + return nil + } + if h == 0 { + panic("Open method: handle must be != 0") + } + return unsafe.Pointer(h) +} + +//export implClose +func implClose(handle unsafe.Pointer) { + pluginImpl.Close(uintptr(handle)) +} + +//export implGetSize +func implGetSize(handle unsafe.Pointer) C.int64_t { + size, err := pluginImpl.GetSize(uintptr(handle)) + if err != nil { + set_error(err) + return -1 + } + return C.int64_t(size) +} + +//expor...
2020 Apr 23
2
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...Id + nextConnectionId++ + connectionMap[id] = h + return unsafe.Pointer(id) +} + +func getConn(handle unsafe.Pointer) ConnectionInterface { + id := uintptr(handle) + h, ok := connectionMap[id] + if !ok { + panic(fmt.Sprintf("connection %d was not open", id)) + } + return h +} + +//export implClose +func implClose(handle unsafe.Pointer) { + h := getConn(handle) + h.Close() + id := uintptr(handle) + delete(connectionMap, id) +} + +//export implGetSize +func implGetSize(handle unsafe.Pointer) C.int64_t { + h := getConn(handle) + size, err := h.GetSize() + if err != nil { + set_error(err) + re...