ocaml: Add support for dynamic .thread_model
commite20176bfd824eb5d79f90dab9c5f8e8bc8e28af7
authorEric Blake <eblake@redhat.com>
Thu, 15 Aug 2019 21:32:16 +0000 (15 16:32 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 16 Aug 2019 13:11:00 +0000 (16 08:11 -0500)
tree379d3bd7c0c7ce2b6645544eda06e18b6c0ea96a
parent892c126b26be3a660cbdfffde639b2702d212d4c
ocaml: Add support for dynamic .thread_model

We do not promise API stability for non-C languages; this is an API
break as follows: instead of calling 'NBDKit.register_plugin model
plugin' with a static model, you can now add .thread_model :(unit ->
thread_model) to plugin, with a default to PARALLEL.  As in C, the
model is chosen at .load time (at most, making it a function allows
you to alter it based on configuration), and not something that can
change per-connection.

Since all existing OCaml plugins will have already thought about
thread models, they can convert their existing model into the new
plugin field (and thus, I don't feel too bad making PARALLEL the
default, even if it is not always the safest).

Signed-off-by: Eric Blake <eblake@redhat.com>
plugins/ocaml/NBDKit.ml
plugins/ocaml/NBDKit.mli
plugins/ocaml/example.ml
plugins/ocaml/nbdkit-ocaml-plugin.pod
plugins/ocaml/ocaml.c
tests/test_ocaml_plugin.ml