summaryrefslogtreecommitdiff
path: root/src/lib/time/sleep.go
blob: f1f0d11ae17857010c7bb2357c80c184bdd9825d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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";
)

// Sleep pauses the current goroutine for ns nanoseconds.
// It returns os.EINTR if interrupted.
func Sleep(ns int64) os.Error {
	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);
}