The function nni_get_interface
returns a pointer to an instance of the Natural Native Interface. One interface
instance can host one Natural session at a time. An application initializes a
Natural session by calling the function nni_initialize
on a given
interface instance. It uninitializes the Natural session by calling
nni_uninitialize
on that
interface instance. After that it can initialize a new Natural session on the
same interface instance.
It is implementation dependent if multiple interface instances and thus multiple Natural
sessions can be maintained per process or per thread. In the current implementation of
Natural for Windows or Linux, one process can host one Natural session at a time.
Consequently, every call to nni_get_interface
in one process yields the same interface
instance. However, this unique interface instance can be used alternating by several
concurrently running threads. The thread synchronization is implicitly performed by the
interface functions themselves. Optionally it can be performed by the application
explicitly. The interface provides the required synchronization functions nni_enter
, nni_try_enter
and nni_leave
.