caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: christophe.raffalli@univ-savoie.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] GC and caml_oldify_local_roots taking too much time
Date: Mon, 19 Jul 2004 17:12:41 +0200 (CEST)	[thread overview]
Message-ID: <20040719.171241.71101703.andrieu@ijm.jussieu.fr> (raw)
In-Reply-To: <40FC2C48.3030402@univ-savoie.fr>

 Christophe Raffalli [Mon, 19 Jul 2004]:
 > 
 > I identified the problem:
 > 
 > Glut.timerFunc does register the callback to each call and therefore 
 > allocate one glocal C root.
 > 
 > However, the callback in never unregistred (I do not know how to do 
 > that) and moreover, I register always the same function and therefore, 
 > it is always the same Global C root which is registered !
 > 
 > Is there a function to unregister a callback ?

No, but you needn't register the callback itself, you can register a
reference to it.

,----
| let callback = ref None
| external setup_c_callback : string -> unit = "setup_c_callback"
| let _ = 
|   let id = "my_caml_callback" in
|   Callback.register id callback ;
|   setup_c_callback id
| 
| let set_callback f = callback := Some f
| let unset_callback () = callback := None
`----

,----
| static value *my_caml_callback;
| 
| static void my_c_callback()
| {
|   if (my_caml_callback != NULL) {
|     value contents = Field(*my_caml_callback, 0);
|     if (Is_block(contents)) {
|       value closure = Field(contents, 0);
|       callback_exn(closure, Val_unit);
|     }
|   }
| }
| 
| CAMLprim value setup_c_callback(value id)
| {
|   my_caml_callback = caml_named_value(String_val(id));
|   setup_callback(&my_c_callback);
| }
`----

That way, Callback.register is only called once.

-- 
   Olivier

-------------------
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


  parent reply	other threads:[~2004-07-19 15:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-19 17:59 Christophe Raffalli
2004-07-19 12:21 ` Damien Doligez
2004-07-19 19:33   ` Christophe Raffalli
2004-07-19 20:17   ` Christophe Raffalli
2004-07-19 14:28     ` Richard Jones
2004-07-19 14:38       ` Richard Jones
2004-07-19 15:12     ` Olivier Andrieu [this message]
2004-07-19 20:36   ` Christophe Raffalli
2004-07-20 20:00   ` [Caml-list] Calback (was caml_oldify_local_roots taking too much time) Christophe Raffalli
2004-07-20 14:40     ` [Caml-list] Calback Olivier Andrieu
     [not found]       ` <40FD9FDE.3070000@univ-savoie.fr>
2004-07-20 22:44         ` Christophe Raffalli
2004-07-21  0:54           ` Jere Sanisalo
2004-07-20 23:09       ` Christophe Raffalli

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=20040719.171241.71101703.andrieu@ijm.jussieu.fr \
    --to=andrieu@ijm.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=christophe.raffalli@univ-savoie.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;
as well as URLs for NNTP newsgroup(s).