mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-24 14:29:08 +00:00
Implement runtime.Sleep
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
// TODO: use the time package for this.
|
||||||
|
|
||||||
|
// #include <unistd.h>
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
type Duration uint64
|
||||||
|
|
||||||
|
// Use microseconds as the smallest time unit
|
||||||
|
const (
|
||||||
|
Microsecond = 1
|
||||||
|
Millisecond = Microsecond * 1000
|
||||||
|
Second = Millisecond * 1000
|
||||||
|
)
|
||||||
|
|
||||||
|
func Sleep(d Duration) {
|
||||||
|
C.usleep(C.useconds_t(d))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user