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

Raimo Niskanen <>
Thu Dec 13 23:06:10 CET 2007


On Thu, Dec 13, 2007 at 09:30:34PM +0000, Joel Reymont wrote:
> Tony,
> 
> You misunderstood my question. It's not _what_ outputv does but how is  
> it possible that efile_drv.c sets up both outputv and output callbacks  
> and both seem to be called somehow.
> 

output is not called as a callback, but from the outputv callback
(that is called by the emulator).

I did not have the time to rewrite all operations into the outputv
callback when I wrote it (before all operations were in output),
so I kept a fallback at the end of outputv to flatten the data
and call output as before.

The output callback should die and all operations should be
moved to outputv. When anyone gets the time.



> At least I assume that they are both being called since the set of  
> functions that the driver performs is split over the two callbacks.  
> The read/write functions are in outputv and a whole bunch of others  
> like mkdir are in output.
> 
> 	Thanks, Joel
> 
> On Dec 13, 2007, at 8:28 PM, Tony Rogvall wrote:
> 
> > 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.
> 
> --
> http://wagerlabs.com
> 
> 
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list