From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id A5AF27F860 for ; Tue, 18 Mar 2014 00:50:34 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of daniel.buenzli@erratique.ch) identity=pra; client-ip=74.55.86.74; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="daniel.buenzli@erratique.ch"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of daniel.buenzli@erratique.ch) identity=mailfrom; client-ip=74.55.86.74; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="daniel.buenzli@erratique.ch"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.webfaction.com) identity=helo; client-ip=74.55.86.74; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="postmaster@smtp.webfaction.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AncPAAuJJ1NKN1ZKnGdsb2JhbABag0GCPYEgvxWBOQ4BAQEBAQYNCQkUKIImAQEEI1YQCw4MAiYCAkcQBhuHcQQJsHuibReBKYtCgUozB4JvNYEUBJ57F48S X-IPAS-Result: AncPAAuJJ1NKN1ZKnGdsb2JhbABag0GCPYEgvxWBOQ4BAQEBAQYNCQkUKIImAQEEI1YQCw4MAiYCAkcQBhuHcQQJsHuibReBKYtCgUozB4JvNYEUBJ57F48S X-IronPort-AV: E=Sophos;i="4.97,673,1389740400"; d="scan'208";a="53050419" Received: from mail6.webfaction.com (HELO smtp.webfaction.com) ([74.55.86.74]) by mail3-smtp-sop.national.inria.fr with ESMTP; 18 Mar 2014 00:50:33 +0100 Received: from [172.20.10.2] (33-237.197-178.cust.bluewin.ch [178.197.237.33]) by smtp.webfaction.com (Postfix) with ESMTP id 73729209C8C4; Mon, 17 Mar 2014 23:50:31 +0000 (UTC) Date: Tue, 18 Mar 2014 00:50:29 +0100 From: =?utf-8?Q?Daniel_B=C3=BCnzli?= To: Richard Neswold Cc: caml-list@inria.fr Message-ID: In-Reply-To: <2F20BDD4-4475-4250-921F-E4CDB34BFD86@gmail.com> References: <1732E7D3-C154-4305-90C8-0CC292FE08CF@gmail.com> <8738ihru8r.fsf@golf.niidar.ru> <3B63CC7A2A994E018E1EC2E450E0FFF4@erratique.ch> <2F20BDD4-4475-4250-921F-E4CDB34BFD86@gmail.com> X-Mailer: sparrow 1.6.4 (build 1178) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Caml-list] OpenGL and LWT Le lundi, 17 mars 2014 =C3=A0 23:50, Richard Neswold a =C3=A9crit : > I could have an Lwt thread call Sdl.poll_event and then go to sleep if no= events were available, but I'm trying to make this driven by events and no= t resort to polling, if possible. There is certainly more than one way to do that, but that's what I do at th= e moment (with another cooperative threading library). Favor the treatement= of the UI events, if there's no UI event run the scheduler for 10ms.=20=20 let rec loop deadline =3D=20=20 while Sdl.poll_event e do do_event e done; run_scheduler ~timeout:10;=20=20 loop () Regarding Tsdl.Sdl.wait_event, it's not really better than that, if you hav= e a look at its C implementation [1] you'll see it tries to get an event an= d if none is available it will sleep for 10ms before trying again. This mea= ns that any SDL based program using Sdl.wait_event, constantly uses ~1.5% c= pu (at least on osx), you should be able to bring that down by writing your= own loop as above and augmenting the timeout value when your application i= s not in the foreground.=20=20 Best, Daniel [1] http://hg.libsdl.org/SDL/file/4c01875a4620/src/events/SDL_events.c#l421