Blame doc/threading.dox

Packit 6c0a39
/**
Packit 6c0a39
@page libssh_tutor_threads Chapter 8: Threads with libssh
Packit 6c0a39
@section threads_with_libssh How to use libssh with threads
Packit 6c0a39
Packit 6c0a39
libssh may be used in multithreaded applications, but under several conditions :
Packit 6c0a39
 - Your system must support libpthread or, in Windows environment,
Packit 6c0a39
   CriticalSection based mutex control.
Packit 6c0a39
 - Since version 0.8.0, threads initialization is called automatically in the
Packit 6c0a39
   library constructor if libssh is dynamically linked. This means it is no
Packit 6c0a39
   longer necessary to call ssh_init()/ssh_finalize().
Packit 6c0a39
 - If libssh is statically linked, threading must be initialized by calling
Packit 6c0a39
   ssh_init() before using any of libssh provided functions. This initialization
Packit 6c0a39
   must be done outside of any threading context. Don't forget to call
Packit 6c0a39
   ssh_finalize() to avoid memory leak
Packit 6c0a39
 - At all times, you may use different sessions inside threads, make parallel
Packit 6c0a39
   connections, read/write on different sessions and so on. You *cannot* use a
Packit 6c0a39
   single session (or channels for a single session) in several threads at the same
Packit 6c0a39
   time. This will most likely lead to internal state corruption. This limitation is
Packit 6c0a39
   being worked out and will maybe disappear later.
Packit 6c0a39
Packit 6c0a39
@subsection threads_init Initialization of threads
Packit 6c0a39
Packit 6c0a39
Since version 0.8.0, it is no longer necessary to call ssh_init()/ssh_finalize()
Packit 6c0a39
if libssh is dynamically linked.
Packit 6c0a39
Packit 6c0a39
If libssh is statically linked, call ssh_init() before using any of libssh
Packit 6c0a39
provided functions.
Packit 6c0a39
Packit 6c0a39
@subsection threads_pthread Using libpthread with libssh
Packit 6c0a39
Packit 6c0a39
Since version 0.8.0, libpthread is the default threads library used by libssh.
Packit 6c0a39
Packit 6c0a39
To use libpthread, simply link it to you application.
Packit 6c0a39
Packit 6c0a39
If you are using libssh statically linked, don't forget to call ssh_init()
Packit 6c0a39
before using any of libssh provided functions (and ssh_finalize() in  the end).
Packit 6c0a39
Packit 6c0a39
@subsection threads_other Using another threading library
Packit 6c0a39
Packit 6c0a39
Since version 0.8.0, libssh does not support custom threading libraries.
Packit 6c0a39
The change makes sense since the newer versions for libcrypto (OpenSSL) and
Packit 6c0a39
libgcrypt don't support custom threading libraries.
Packit 6c0a39
Packit 6c0a39
The default used threading library is libpthread.
Packit 6c0a39
Alternatively, in Windows environment, CriticalSection based mutex control can
Packit 6c0a39
be used.
Packit 6c0a39
Packit 6c0a39
If your system does not support libpthread nor CriticalSection based mutex
Packit 6c0a39
control, unfortunately, you cannot use libssh in multithreaded scenarios.
Packit 6c0a39
Packit 6c0a39
Good luck !
Packit 6c0a39
*/