mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
finish ChanValue: Len and Cap.
R=r DELTA=45 (45 added, 0 deleted, 0 changed) OCL=33873 CL=33881
This commit is contained in:
parent
653cef1ba0
commit
de7920e6fd
5 changed files with 45 additions and 0 deletions
|
|
@ -636,6 +636,8 @@ func chansend(ch, val *byte, pres *bool)
|
|||
func chanrecv(ch, val *byte, pres *bool)
|
||||
func chanclosed(ch *byte) bool
|
||||
func chanclose(ch *byte)
|
||||
func chanlen(ch *byte) int32
|
||||
func chancap(ch *byte) int32
|
||||
|
||||
// Closed returns the result of closed(c) on the underlying channel.
|
||||
func (v *ChanValue) Closed() bool {
|
||||
|
|
@ -649,6 +651,16 @@ func (v *ChanValue) Close() {
|
|||
chanclose(ch);
|
||||
}
|
||||
|
||||
func (v *ChanValue) Len() int {
|
||||
ch := *(**byte)(v.addr);
|
||||
return int(chanlen(ch));
|
||||
}
|
||||
|
||||
func (v *ChanValue) Cap() int {
|
||||
ch := *(**byte)(v.addr);
|
||||
return int(chancap(ch));
|
||||
}
|
||||
|
||||
// internal send; non-blocking if b != nil
|
||||
func (v *ChanValue) send(x Value, b *bool) {
|
||||
t := v.Type().(*ChanType);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue