~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/pkg/time/sleep_test.go

  • Committer: Package Import Robot
  • Author(s): Ondřej Surý, Ondřej Surý, Michael Stapelberg
  • Date: 2012-06-28 12:14:15 UTC
  • mfrom: (1.1.15)
  • mto: (3.1.5 experimental) (14.3.1 saucy)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20120628121415-w1b0076ixkarr1ml
[ Ondřej Surý ]
* Imported Upstream version 1.0.2
* Update Vcs fields to reflect new git repository location
* Kill get-orig-source, since 1.0.0, the tarballs can be downloaded
  from webpage

[ Michael Stapelberg ]
* golang-mode: use debian-pkg-add-load-path-item (Closes: #664802)
* Add manpages (Closes: #632964)
* Use updated pt.po from Pedro Ribeiro (Closes: #674958)

Show diffs side-by-side

added added

removed removed

Lines of Context:
223
223
        }
224
224
        Sleep(3 * Second)
225
225
}
 
226
 
 
227
func TestSleepZeroDeadlock(t *testing.T) {
 
228
        // Sleep(0) used to hang, the sequence of events was as follows.
 
229
        // Sleep(0) sets G's status to Gwaiting, but then immediately returns leaving the status.
 
230
        // Then the goroutine calls e.g. new and falls down into the scheduler due to pending GC.
 
231
        // After the GC nobody wakes up the goroutine from Gwaiting status.
 
232
        defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
 
233
        c := make(chan bool)
 
234
        go func() {
 
235
                for i := 0; i < 100; i++ {
 
236
                        runtime.GC()
 
237
                }
 
238
                c <- true
 
239
        }()
 
240
        for i := 0; i < 100; i++ {
 
241
                Sleep(0)
 
242
                tmp := make(chan bool, 1)
 
243
                tmp <- true
 
244
                <-tmp
 
245
        }
 
246
        <-c
 
247
}