You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears all the Go implementations of serial drivers are not asynchronous. This is fine, because in Go you can use goroutine to wait on blocked code. However, cancellation would be expected, but it's not available. Currently, the only way to cancel a Read or Write is to close the serial port, which cancels every operation, rather than the specific operation you want cancelled.
Regarding cancellation on Windows:
CancelIoEx function: "The CancelIoEx function allows you to cancel requests in threads other than the calling thread. The CancelIo function only cancels requests in the same thread that called the CancelIo function."
This is important in Go, because goroutines are scheduled across multiple threads usually, and there is no guarantee which thread a piece of code is currently running on.
Canceling Pending I/O Operations: "When canceling asynchronous I/O, when no overlapped structure is supplied to CancelIoEx, the function attempts to cancel all outstanding I/O on the file on all threads in the process."
This implies that providing the overlapped structure cancels only that I/O operation.
WriteFile function (fileapi.h): "The WriteFile function returns when one of the following conditions occur: - An asynchronous handle is being used and the write is occurring asynchronously."
According to my testing, when cancelling overlapped IO, GetOverlappedResult returns failure with the ERROR_OPERATION_ABORTED error.
The Unix implementation can be added to easily, since it's already "select"ing over the port handle and a cancellation handle used only when closing the port.
Timeouts would also be possible through system calls, but that is a less ideal, because Go can easily do timeouts on its own. So I think adding cancellation satisfies any need for setting timeouts.
The text was updated successfully, but these errors were encountered:
It appears all the Go implementations of serial drivers are not asynchronous. This is fine, because in Go you can use goroutine to wait on blocked code. However, cancellation would be expected, but it's not available. Currently, the only way to cancel a Read or Write is to close the serial port, which cancels every operation, rather than the specific operation you want cancelled.
Regarding cancellation on Windows:
This is important in Go, because goroutines are scheduled across multiple threads usually, and there is no guarantee which thread a piece of code is currently running on.
This implies that providing the overlapped structure cancels only that I/O operation.
The Unix implementation can be added to easily, since it's already "select"ing over the port handle and a cancellation handle used only when closing the port.
Timeouts would also be possible through system calls, but that is a less ideal, because Go can easily do timeouts on its own. So I think adding cancellation satisfies any need for setting timeouts.
The text was updated successfully, but these errors were encountered: