Moved Pipe{} into own sub-package

It may be moved into a separate project at some point, who knows...
This commit is contained in:
Cristian Maglie
2016-11-13 23:44:13 +01:00
parent eee219b43f
commit 152558831e
3 changed files with 85 additions and 56 deletions

View File

@@ -16,6 +16,8 @@ import (
"syscall"
"unsafe"
"go.bug.st/serial.v1/unixutils"
"github.com/creack/goselect"
)
@@ -23,7 +25,7 @@ type unixPort struct {
handle int
closeLock sync.RWMutex
closeSignal *pipe
closeSignal *unixutils.Pipe
}
func (port *unixPort) Close() error {
@@ -137,8 +139,8 @@ func nativeOpen(portName string, mode *Mode) (*unixPort, error) {
port.acquireExclusiveAccess()
// This pipe is used as a signal to cancel blocking Read or Write
pipe, err := newPipe()
if err != nil {
pipe := &unixutils.Pipe{}
if err := pipe.Open(); err != nil {
port.Close()
return nil, &PortError{code: InvalidSerialPort, causedBy: err}
}