void runtime·closechan(Hchan *c) { SudoG *sg; G* gp; if(c == nil) runtime·panicstring("close of nil channel"); if(runtime·gcwaiting) runtime·gosched(); runtime·lock(c); if(c->closed) { runtime·unlock(c); runtime·panicstring("close of closed channel"); } if(raceenabled) { runtime·racewritepc(c, runtime·getcallerpc(&c), runtime·closechan); runtime·racerelease(c); } c->closed = true; // release all readers for(;;) { sg = dequeue(&c->recvq); if(sg == nil) break; gp = sg->g; gp->param = nil; runtime·ready(gp); } // release all writers for(;;) { sg = dequeue(&c->sendq); if(sg == nil) break; gp = sg->g; gp->param = nil; runtime·ready(gp); } runtime·unlock(c); }
static void closechan ( Hchan *c , void *pc ) { SudoG *sg; G* gp; #line 1041 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc" if ( c == nil ) runtime·panicstring ( "close of nil channel" ) ; #line 1044 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc" runtime·lock ( c ) ; if ( c->closed ) { runtime·unlock ( c ) ; runtime·panicstring ( "close of closed channel" ) ; } #line 1050 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc" if ( raceenabled ) { runtime·racewritepc ( c , pc , runtime·closechan ) ; runtime·racerelease ( c ) ; } #line 1055 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc" c->closed = true; #line 1058 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc" for ( ;; ) { sg = dequeue ( &c->recvq ) ; if ( sg == nil ) break; gp = sg->g; gp->param = nil; if ( sg->releasetime ) sg->releasetime = runtime·cputicks ( ) ; runtime·ready ( gp ) ; } #line 1070 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc" for ( ;; ) { sg = dequeue ( &c->sendq ) ; if ( sg == nil ) break; gp = sg->g; gp->param = nil; if ( sg->releasetime ) sg->releasetime = runtime·cputicks ( ) ; runtime·ready ( gp ) ; } #line 1081 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc" runtime·unlock ( c ) ; }
static void closechan ( Hchan *c , void *pc ) { SudoG *sg; G* gp; #line 1045 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc" if ( c == nil ) runtime·panicstring ( "close of nil channel" ) ; #line 1048 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc" runtime·lock ( c ) ; if ( c->closed ) { runtime·unlock ( c ) ; runtime·panicstring ( "close of closed channel" ) ; } #line 1054 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc" if ( raceenabled ) { runtime·racewritepc ( c , pc , runtime·closechan ) ; runtime·racerelease ( c ) ; } #line 1059 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc" c->closed = true; #line 1062 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc" for ( ;; ) { sg = dequeue ( &c->recvq ) ; if ( sg == nil ) break; gp = sg->g; gp->param = nil; if ( sg->releasetime ) sg->releasetime = runtime·cputicks ( ) ; runtime·ready ( gp ) ; } #line 1074 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc" for ( ;; ) { sg = dequeue ( &c->sendq ) ; if ( sg == nil ) break; gp = sg->g; gp->param = nil; if ( sg->releasetime ) sg->releasetime = runtime·cputicks ( ) ; runtime·ready ( gp ) ; } #line 1085 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc" runtime·unlock ( c ) ; }