diff options
author | Hans Nilsson <[email protected]> | 2016-10-14 10:15:13 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-10-14 10:15:13 +0200 |
commit | 9eee0bb5cc74d037ce89521b9a1fec4a289e4880 (patch) | |
tree | 7f41e1612c113f8beb50d3e8b2e26155dd00a3d7 /lib/ssh/test/ssh_test_lib.erl | |
parent | 3d925002ceed8f0a739e17e65643a20f6c3f1142 (diff) | |
parent | df8c6690a86d087d8de324276b2266bc5918c779 (diff) | |
download | otp-9eee0bb5cc74d037ce89521b9a1fec4a289e4880.tar.gz otp-9eee0bb5cc74d037ce89521b9a1fec4a289e4880.tar.bz2 otp-9eee0bb5cc74d037ce89521b9a1fec4a289e4880.zip |
Merge branch 'maint'
Conflicts:
OTP_VERSION
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. + +%%%---------------------------------------------------------------- |