[erlang-questions] Linked-in drivers: output and outputv callbacks

Tony Rogvall tony@REDACTED
Thu Dec 13 21:28:24 CET 2007


There is actually quite some descent docs to read here:


http://www.erlang.org/doc/apps/erts/index.html

void outputv(ErlDrvData drv_data, ErlIOVec *ev)

This function is called whenever the port is written to. If it is  
NULL, the output function is called instead. This function is faster  
than output, because it takes an ErlIOVec directly, which requires no  
copying of the data. The port should be in binary mode, see open_port/2.

The ErlIOVec contains both a SysIOVec, suitable for writev, and one or  
more binaries. If these binaries should be retained, when the driver  
returns from outputv, they can be queued (using driver_enq_bin for  
instance), or if they are kept in a static or global variable, the  
reference counter can be incremented.

On 13 dec 2007, at 20.15, Joel Reymont wrote:

> I'm studying the source for the efile driver in efile_drv.c as well as
> the matching Erlang code in prim_file.erl.
>
> For the life of me I cannot figure out how FILE_WRITE gets to be
> handled in file_outputv and FILE_MKDIR in file_output. Both are
> triggered from port_command/2 on the Erlang side and both callbacks
> are set in the driver entry structure.
>
> How does the runtime figure out whether to call the output callback or
> the outputv callback when both are supplied?
>
> According to erts_write_to_port in erts/emulator/beam/io.c, the output
> callback will never be called when the output callback is present the
> function checks for outputv first.
>
> 	Thanks, Joel
>
> --
> http://wagerlabs.com
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071213/951a7705/attachment.htm>


More information about the erlang-questions mailing list