Timer
commitcbd5206e4f70463d06b3ab09d3aeb562ba9a2066
authorGabe Levi <gabe@fb.com>
Tue, 18 Jul 2017 15:49:38 +0000 (18 08:49 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Tue, 18 Jul 2017 16:06:39 +0000 (18 09:06 -0700)
tree0326efb10b2c6613aa95e568a02abb42f77d4303
parent879c484d7ab0d8452874dce3d5229eb3f72ff303
Timer

Summary:
This adds a Timer util which allows you to schedule a callback when a
timer fires. Since this uses `Unix.setitimer`, it won't work on Windows.

I intend to use this in two ways:

I'll update `Timeout.Alarm_timeout` to use this, since `Alarm_timeout` has
this old bug where nesting timeouts don't quite work correctly (the outer
timout gets paused while the inner one runs). This is a necessary change, since
you can't have two utils both use sigalrm.

I also want to use this for profiling. I want to sample cpu/memory/etc
repeatedly and this seems like a good way to do so.

Reviewed By: alexchow

Differential Revision: D5227380

fbshipit-source-id: d8c9c6a2da6f0bdde3173ab2fe4b921bac4dfaf6
hphp/hack/src/utils/timer.ml [new file with mode: 0644]
hphp/hack/src/utils/timer.mli [new file with mode: 0644]
hphp/hack/test/unit/utils/timer_test.ml [new file with mode: 0644]