From: Fabrice Marchant <fabrice.marchant@orange.fr>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Why 'Graphics.wait_next_event' doesn't reply anymore ?
Date: Sun, 11 Nov 2007 20:40:19 +0100 [thread overview]
Message-ID: <20071111204019.4697d387@localhost.localdomain> (raw)
In-Reply-To: <1194799714.473732620f33e@webmail.in-berlin.de>
Hi Oliver !
Thanks to have considered my problem.
On Sun, 11 Nov 2007 17:48:34 +0100
Oliver Bandel <oliver@first.in-berlin.de> wrote:
> http://caml.inria.fr/pub/ml-archives/caml-list/2002/09/d29ca3379fe68e3cdbd36323f5f409c0.en.html
> This code looks ugly.
...
> It forces calls to the scheduler all too often.
> And it does it at three places. And in the print-loop
> it clals it every time!
> This is the way of wasting ressources.
I think these 'yields' are only desperate attempts to hint the scheduler to do its job - that it doesn't as we could expected -.
> open Thread
> open Graphics
>
>
> let code1 () =
> let x = ref 0 in
> while true do
> incr x;
> Printf.printf "alpha %d\n" !x;
> flush stdout
(* ;
display_mode false;
fill_circle 100 100 20;
synchronize ()*)
> done
>
> let code2 () =
> open_graph " 300x300";
> while true do
> let st = wait_next_event [Key_pressed] in
> Printf.printf "key %c pressed...\n" st.key;
> flush stdout
> done
>
> let _ =
> ignore(Thread.create code1());
> code2()
Yes, it perfectly works.
So I compared it with my hanging example to try to understood what was responsible for blocking.
If you uncomment the lines I inserted in code1, things begins to go more or less wrong.
On my computer, from time to time, when you alternatively focus console output and graphical window, some characters can be suddenly spat. Or keyboard input is completely ignored...
Thanks to have make things progress ! I think we aren't far to understand.
Regards,
Fabrice
next prev parent reply other threads:[~2007-11-11 20:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-10 22:01 Fabrice Marchant
2007-11-11 14:07 ` [Caml-list] " Fabrice Marchant
2007-11-11 16:48 ` Oliver Bandel
2007-11-11 18:35 ` Julien Moutinho
2007-11-11 20:13 ` Fabrice Marchant
2007-11-12 0:33 ` Oliver Bandel
2007-11-11 19:40 ` Fabrice Marchant [this message]
2007-11-12 0:43 ` Oliver Bandel
2007-11-12 19:54 ` Fabrice Marchant
2007-11-12 21:18 ` Oliver Bandel
2007-11-13 7:45 ` Fabrice Marchant
2007-11-13 10:14 ` Oliver Bandel
2007-11-13 20:10 ` Fabrice Marchant
2007-11-14 0:33 ` Oliver Bandel
2007-11-12 0:46 ` Oliver Bandel
2007-11-12 6:18 ` Oliver Bandel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071111204019.4697d387@localhost.localdomain \
--to=fabrice.marchant@orange.fr \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox