blob: 6a592bc420c27f2507232d77cddcaac8b376a4eb [file] [log] [blame]
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package zx
import "sync/atomic"
type Socket Handle
type Event Handle
type Channel Handle
type Port Handle
type VMO Handle
type VMAR Handle
type Log Handle
func (s *Socket) Handle() *Handle {
return (*Handle)(s)
}
func (e *Event) Handle() *Handle {
return (*Handle)(e)
}
func (c *Channel) Handle() *Handle {
return (*Handle)(c)
}
func (p *Port) Handle() *Handle {
return (*Handle)(p)
}
func (vmo *VMO) Handle() *Handle {
return (*Handle)(vmo)
}
func (l *Log) Handle() *Handle {
return (*Handle)(l)
}
func (h *Handle) Load() Handle {
return Handle(atomic.LoadUint32((*uint32)(h)))
}
func (h *Handle) IsValid() bool {
return h.Load() > HandleInvalid
}
const (
ChannelMaxMessageBytes = 65536
ChannelMaxMessageHandles = 64
)