Skip to content
This repository was archived by the owner on Oct 18, 2020. It is now read-only.

Sleep nsec#168

Merged
yomimono merged 2 commits intomirage:masterfrom
hannesm:sleep-nsec
Jul 28, 2016
Merged

Sleep nsec#168
yomimono merged 2 commits intomirage:masterfrom
hannesm:sleep-nsec

Conversation

@yomimono
Copy link
Copy Markdown
Contributor

Requires mirage/mirage#547 .


(** Timeout operations. *)

val sleep : float -> unit Lwt.t
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being removed? It's OK to add a new function if we need to, but removing the old one serves no purpose.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Thought part of the point of this was to remove need for floats?)

On 29 June 2016 at 14:04, Thomas Leonard notifications@github.com wrote:

In unix/lib/time.mli
#168 (comment):

@@ -18,6 +18,6 @@ type +'a io = 'a Lwt.t

(** Timeout operations. *)

-val sleep : float -> unit Lwt.t

Why is this being removed? It's OK to add a new function if we need to,
but removing the old one serves no purpose.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mirage/mirage-platform/pull/168/files/d03e97408093e46d4f779db72c2be0f1b878f770#r68941502,
or mute the thread
https://github.com/notifications/unsubscribe/AAKP4KhO7u6JvbYTJqSelXadRiPhqlvYks5qQm14gaJpZM4JBE6e
.

Richard Mortier
mort@cantab.net

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@talex5 what is the purpose of keeping the function? my impression was that mirage-unix/xen is an implementation of (some of the modules defined in) mirage-types...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It's used in lots of places and there's no need to break everything.
  • OCaml uses floats to represent times, so having something that accepts OCaml times is useful.
  • Using floats allows representing very long or short durations without errors.
  • Using floats avoids error-prone scaling (e.g. all the * 1_000_000_000 magic constants in the recent patches).
  • Using floats avoids overflow errors when converting between timebases (e.g. duration_at_freq_1 /. freq_1 *. freq_2 works; using int64 might not, depending on the frequencies and duration).

In general, it's conveniet, familiar and safe. So for code that doesn't care about performance, I'd prefer to stick to floats.

Copy link
Copy Markdown
Member

@hannesm hannesm Jul 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wrote up a durations library for easy conversion from your favourite time representation (microseconds, milliseconds, seconds, minutes, hours, years as int), seconds as floating point number) to nanoseconds (and the inverse). A uint64 representing nanoseconds allows for a range up to 584 years, that should be sufficient for sleep durations.

IMHO OCaml uses floats is a mistake (and the queued changes to PCLOCK/MCLOCK inside of mirage-types will get rid of this mistake inside of mirage).

@yomimono yomimono merged commit 06d5382 into mirage:master Jul 28, 2016
@hannesm hannesm deleted the sleep-nsec branch July 28, 2016 16:04
TheLortex pushed a commit to TheLortex/mirage-platform that referenced this pull request Feb 14, 2019
a844d58 Merge pull request mirage#176 from JuliaLang/aa/openbsd
72bfab4 Avoid redefining macros defined by the system
48c6c2c Use cp -RpP instead of cp -a
bf188ae Build with Clang on OpenBSD
b7b3b4b Merge pull request mirage#175 from takuyanakaoka/fix-sincosl
d134c84 Fix reversed outputs of sincosl
c99ab08 Merge pull request mirage#173 from pkofod/patch-1
3db5e54 Minor typo in expm1 comment
b252047 Merge pull request mirage#168 from JuliaLang/yyc/ld128
238a909 Fix compilation on AArch64
3ff5216 Merge pull request mirage#162 from JuliaLang/aa/0.5.5
7cf4e9e Merge pull request mirage#164 from iblis17/test-cflags
bd6d0e1 test: update ulps for yn
400407e test: append $(CFLAGS_add), which includes fno-builtin
ddf649b enable -fno-strict-aliasing for clang (mirage#156)
c3968ca Allow building on DragonFly BSD (mirage#167)
7e726c3 Bump version to 0.5.5
b11e72b Set the RPATH for the test binaries on FreeBSD (mirage#161)

git-subtree-dir: openlibm
git-subtree-split: a844d584d36fcb117c7880d87b806ff84b20f378
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants