• Russ Cox's avatar
    runtime: refactor routines for stopping, running goroutine from m · 64c2083e
    Russ Cox authored
    This CL adds 'dropg', which is called to drop the association
    between m and its current goroutine, and it makes schedule
    handle locked goroutines correctly, instead of requiring all
    callers of schedule to do that.
    
    The effect is that if you want to take over an m for, say,
    garbage collection work while still allowing the current g
    to run on some other m, you can do an mcall to a function
    that is:
    
            // dissociate gp
            dropg();
            gp->status = Gwaiting; // for ready
    
            // put gp on run queue for others to find
            runtime·ready(gp);
    
            /* ... do other work here ... */
    
            // done with m, let it run goroutines again
            schedule();
    
    Before this CL, the dropg() body had to be written explicitly,
    and the check for lockedg before schedule had to be
    written explicitly too, both of which make the code a bit
    more fragile than it needs to be.
    
    LGTM=iant
    R=dvyukov, iant
    CC=golang-codereviews, rlh
    https://golang.org/cl/113110043
    64c2083e
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
include Loading commit data...
lib Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...