make indexes optional for the asciidoc plugin of pipadoc
[nobug.git] / doc / multithreading.txt
blob032f00c6eb9f2905f530fc501339f504d5f4ac3f
1 [[multithreading]]
2 Multithreading
4 It is important that NoBug protects certain operations with locks in
5 multithreaded programs. You have to ensure that 'HAVE_PTHREAD_H' is defined by
6 the configuration system and use the 'libnobugmt.a' library for linking. It is
7 particular important that libraries using NoBug are compiled with
8 'HAVE_PTHREAD_H' enabled when they are intended to be used in multithreaded
9 programs.
11 When Multithreading is used, log messages contain a identifier of the
12 originating thread. This identifier should be set by
14   * NOBUG_THREAD_ID_SET(name)
16 right after thread creation. name is a string describing the purpose of the
17 thread. Nobug will assemble a unique identifier by appending a underscore and a
18 number to name, for example NOBUG_THREAD_ID_SET("gui") will result in a
19 identifier like "gui_5". When you don't set a thread identifier, then NoBug
20 assigns one automatically with the name 'thread' preprended if needed. Thread
21 identifiers are immutable once set.
23 For querying the thread identifier you use
25   * NOBUG_THREAD_ID_GET
27 which will return a const char* to the thread id in multithreaded programs and
28 a pointer to a literal "" in singlethreaded programs.