caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Unix.sleep in toplevel
@ 2002-09-06  5:53 Oleg
  2002-09-06  6:26 ` Oleg
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg @ 2002-09-06  5:53 UTC (permalink / raw)
  To: caml-list

Hi

I wonder why Unix.sleep does not work in toplevel? (ocaml3.04/debian) The 
manual does not mention anything special.

Thanks
Oleg
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Unix.sleep in toplevel
  2002-09-06  5:53 [Caml-list] Unix.sleep in toplevel Oleg
@ 2002-09-06  6:26 ` Oleg
  2002-09-06  6:37   ` Laure Danthony
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg @ 2002-09-06  6:26 UTC (permalink / raw)
  To: caml-list

On Friday 06 September 2002 01:53 am, Oleg wrote:
> Hi
>
> I wonder why Unix.sleep does not work in toplevel? (ocaml3.04/debian) The
> manual does not mention anything special.

Clarification: Unix.sleep doesn't work only after Graphics.open_graph has 
been called, as it turned out (probably part of the same problem with threads 
+ graphics)

Thanks
Oleg
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Unix.sleep in toplevel
  2002-09-06  6:26 ` Oleg
@ 2002-09-06  6:37   ` Laure Danthony
  0 siblings, 0 replies; 3+ messages in thread
From: Laure Danthony @ 2002-09-06  6:37 UTC (permalink / raw)
  To: caml-list

Le Fri, Sep 06, 2002 at 02:26:40AM -0400, Oleg écrivait:
> Clarification: Unix.sleep doesn't work only after Graphics.open_graph has 
> been called, as it turned out (probably part of the same problem
> with threads + graphics)


So here is the solution X.Leroy's gave to me one year ago :

-----------------------------------
(caml-list)

[English summary: Laure observed that Unix.sleep returns early when
the graphics window is open.  Under Unix, the graphics library uses
signals for event processing, and on many Unix systems, Unix.sleep
returns early when interrupted by a signal.  Here is an alternate
implementation of sleep that is robust against signals.]

let mysleep n =
  let start = Unix.gettimeofday() in
  let rec delay t =
    try
      ignore (Unix.select [] [] [] t)
    with Unix.Unix_error(Unix.EINTR, _, _) ->
      let now = Unix.gettimeofday() in
      let remaining = start +. n -. now in
      if remaining > 0.0 then delay remaining in
  delay n

-----------------------------

Notice that n is a float instead of an int.

Hope this helps,

Laure Danthony

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-06  6:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-06  5:53 [Caml-list] Unix.sleep in toplevel Oleg
2002-09-06  6:26 ` Oleg
2002-09-06  6:37   ` Laure Danthony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).