On Mon, Apr 4, 2011 at 12:31 PM, Guillaume Yziquel
<[email protected]> wrote:
> Le Monday 04 Apr 2011 à 12:17:01 (+0100), Pedro Borges a écrit :

>> Unfortunately implementing zero-copy in ocaml is impossible, AFAIK,
>> without blocking every other thread. If another thread makes an
>> allocation the GC might move the string you are trying to send.
>
> Not so.
>
> There are multiple solutions. You can allocate your stuff out of the GC,
> and the GC will not compact the heap that it doesn't own.

If I allocate a buffer outside the heap, the buffer from ocaml (a
string) would have to be memcpy'ed to the buffer.

> You also the cute caml_register_generational_global_root function if you want 
> buffers
> that are sort of fixed.

That approach looks promising.

> There is also the fact that when OCaml code enters a C stub, there is no 
> OCaml code running at the same time (global master lock mechanism).

That is the "stop all threads" solution I talked about.
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to