Skip to content

Commit

Permalink
conn: Add noCopy
Browse files Browse the repository at this point in the history
Closes #349
  • Loading branch information
nhooyr committed Oct 13, 2023
1 parent b4b86b9 commit a6b9464
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conn.go
Expand Up @@ -42,6 +42,8 @@ const (
// This applies to context expirations as well unfortunately.
// See https://github.com/nhooyr/websocket/issues/242#issuecomment-633182220
type Conn struct {
noCopy

subprotocol string
rwc io.ReadWriteCloser
client bool
Expand Down Expand Up @@ -288,3 +290,6 @@ func (m *mu) unlock() {
default:
}
}

type noCopy struct{}
func (*noCopy) Lock() {}
4 changes: 4 additions & 0 deletions ws_js.go
Expand Up @@ -40,6 +40,7 @@ const (

// Conn provides a wrapper around the browser WebSocket API.
type Conn struct {
noCopy
ws wsjs.WebSocket

// read limit for a message in bytes.
Expand Down Expand Up @@ -563,3 +564,6 @@ func (m *mu) unlock() {
default:
}
}

type noCopy struct{}
func (*noCopy) Lock() {}

0 comments on commit a6b9464

Please sign in to comment.