[erlang-questions] Wrapping C libraries in pure Erlang

Denis Bilenko denis.bilenko@REDACTED
Wed Apr 4 20:32:21 CEST 2007


Serge Aleynikov wrote:

> Part of the issue is that this approach would make it possible for a
> function call inside a 3rd party library to block for a while.  Since
> Erlang's concurrency is dependent on the fact that function calls are
> very short, and the emulator uses reduction-based counting for giving
> CPU slices to each light-weight process a blocking call would
> significantly inhibit concurrency.

For that case, imaginary library 'cee' has function 'cast' that instructs
driver to call function asynchronously, as you have mentioned below.

> Drivers solve this problem by allowing asynchronous invocation of
> blocking functions in the context of threads different from the
> emulator(s) (*).  In case of a driver or a port, once you are on the
> C-side of coding interface, you can make calls to any 3rd party library
> directly without needing FFI (except for cases of functions with
> variable arguments), which may bring you to the question of why bother
> with such an Erlang library if you already have ports and drivers that
> can be written in C or even ei interface for writing C-nodes that can
> make any C-calls safely with respect to the emulator?

Because, if I had such a library I would not have to bother
with C, ei, driver interface.
The point is, why manipulate Erlang data structures from C instead of
manipulating C data structures from Erlang.
Latter approach has to be more productive for (Erlang) programmer.

Denis.



More information about the erlang-questions mailing list