diff options
author | Hans Nilsson <[email protected]> | 2016-10-14 10:14:08 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-10-14 10:14:08 +0200 |
commit | df8c6690a86d087d8de324276b2266bc5918c779 (patch) | |
tree | 9f4212bfb907d69ad0aae9969ee02d12562ea4fb /lib/ssh/test/ssh_test_lib.erl | |
parent | 28d84f10b99906d44d4bb842f17ecc4472cb3d92 (diff) | |
parent | c1c2149818396bdefe9eff995184f8864f18fca3 (diff) | |
download | otp-df8c6690a86d087d8de324276b2266bc5918c779.tar.gz otp-df8c6690a86d087d8de324276b2266bc5918c779.tar.bz2 otp-df8c6690a86d087d8de324276b2266bc5918c779.zip |
Merge branch 'maint-19' into maint
Diffstat (limited to 'lib/ssh/test/ssh_test_lib.erl')
-rw-r--r-- | lib/ssh/test/ssh_test_lib.erl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl index 6233680dce..c43c6519f9 100644 --- a/lib/ssh/test/ssh_test_lib.erl +++ b/lib/ssh/test/ssh_test_lib.erl @@ -767,3 +767,28 @@ open_port(Arg1, ExtraOpts) -> use_stdio, overlapped_io, hide %only affects windows | ExtraOpts]). + +%%%---------------------------------------------------------------- +%%% Sleeping + +%%% Milli sec +sleep_millisec(Nms) -> receive after Nms -> ok end. + +%%% Micro sec +sleep_microsec(Nus) -> + busy_wait(Nus, erlang:system_time(microsecond)). + +busy_wait(Nus, T0) -> + T = erlang:system_time(microsecond) - T0, + Tleft = Nus - T, + if + Tleft > 2000 -> + sleep_millisec((Tleft-1500) div 1000), % μs -> ms + busy_wait(Nus,T0); + Tleft > 1 -> + busy_wait(Nus, T0); + true -> + T + end. + +%%%---------------------------------------------------------------- |