2009-02-16 17:07:11 -08:00
|
|
|
// Copyright 2009 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 time
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os";
|
|
|
|
|
"syscall";
|
|
|
|
|
"unsafe";
|
|
|
|
|
)
|
|
|
|
|
|
2009-03-07 16:56:05 -08:00
|
|
|
// Sleep pauses the current goroutine for ns nanoseconds.
|
|
|
|
|
// It returns os.EINTR if interrupted.
|
2009-04-17 00:08:24 -07:00
|
|
|
func Sleep(ns int64) os.Error {
|
2009-02-16 17:07:11 -08:00
|
|
|
var tv syscall.Timeval;
|
|
|
|
|
syscall.Nstotimeval(ns, &tv);
|
|
|
|
|
r1, r2, err := syscall.Syscall6(syscall.SYS_SELECT, 0, 0, 0, 0,
|
|
|
|
|
int64(uintptr(unsafe.Pointer(&tv))), 0);
|
|
|
|
|
return os.ErrnoToError(err);
|
|
|
|
|
}
|
|
|
|
|
|