mt-libtt.sgm 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <!-- $XConsortium: mt-libtt.sgm /main/4 1996/08/30 15:17:54 rws $ -->
  2. <!-- (c) Copyright 1996 Digital Equipment Corporation. -->
  3. <!-- (c) Copyright 1996 Hewlett-Packard Company. -->
  4. <!-- (c) Copyright 1996 International Business Machines Corp. -->
  5. <!-- (c) Copyright 1996 Sun Microsystems, Inc. -->
  6. <!-- (c) Copyright 1996 Novell, Inc. -->
  7. <!-- (c) Copyright 1996 FUJITSU LIMITED. -->
  8. <!-- (c) Copyright 1996 Hitachi. -->
  9. <![ %CDE.C.CDE; [<RefEntry Id="CDE.TT.mt-libtt">]]>
  10. <RefMeta>
  11. <RefEntryTitle>mt-libtt-intro
  12. </RefEntryTitle>
  13. <ManVolNum>special file</ManVolNum>
  14. </RefMeta>
  15. <RefNameDiv>
  16. <RefName>mt-libtt-intro</RefName>
  17. <RefPurpose>introduction to multi-thread safe ToolTalk library.
  18. </RefPurpose>
  19. </RefNameDiv>
  20. <RefSect1>
  21. <Title>DESCRIPTION</Title>
  22. <para>To enable developers to write multithreaded applications, the <Filename Role="Header">Tt/tt_c.h</Filename> header defines the following features:
  23. </para>
  24. <programlisting>
  25. typedef enum tt_feature {
  26. _TT_FEATURE_MULTITHREADED = 1, // Thread-safety
  27. _TT_FEATURE_LAST // Enum end marker
  28. } Tt_feature;
  29. </programlisting>
  30. <para>Note that the <systemitem class="constant">TT_FEATURE_MULTITHREADED</systemitem>
  31. value is part of the <literal>libtt</literal> binary interface.
  32. </para>
  33. <para>These features are accessed by calling code with corresponding
  34. <literal>#define</literal> constants:
  35. </para>
  36. <programlisting>
  37. #define TT_FEATURE_MULTITHREADED _TT_FEATURE_MULTITHREADED
  38. </programlisting>
  39. <para>Developers can write multi-threaded applications for ToolTalk without
  40. managing locks around ToolTalk resources explicitly in application code.
  41. Note that threading inside ToolTalk is not supported.
  42. </para>
  43. <para>An extended version of the <filename>Xthreads.h</filename> thread API
  44. wrappers has been used so that multithreaded <filename>libtt</filename>
  45. is easily portable to various thread implementations.
  46. </para>
  47. <para>A process-wide lock is used to protect internal
  48. <filename>libtt</filename> resources. Because few applications spend a
  49. significant amount of their time in <filename>libtt</filename>, a more
  50. fine-grained locking approach is not required.
  51. </para>
  52. <para>A few ToolTalk global values, such as the default
  53. <literal>procid</literal> and the storage stack manipulated by the
  54. <function>tt_mark</function> and <function>tt_release</function> calls,
  55. must have a consistent state as seen by one thread across ToolTalk API
  56. calls. These global values have been made into thread-specific data. The calls
  57. described below are used to initialize this behavior and manipulate the new
  58. data. The other API calls have been modified to reference the
  59. thread-specific value instead of the process-wide value when a
  60. thread-specific value has been set for the current thread. If no
  61. thread-specific value has been set for the current thread, the
  62. process-wide value is used.
  63. </para>
  64. <para>The following ToolTalk API calls implement support for
  65. multithreaded <filename>libtt</filename>:
  66. </para>
  67. <VariableList>
  68. <VarListEntry>
  69. <Term><Function>tt_feature_enabled</Function></Term>
  70. <ListItem>
  71. <Para>Queries the ToolTalk service to see if a specified feature has been
  72. enabled. This allows <filename>libtt</filename> to determine if
  73. multithreaded execution has been enabled by the main program, and to
  74. modify its behavior accordingly.
  75. </Para>
  76. </ListItem>
  77. </VarListEntry>
  78. <VarListEntry>
  79. <Term><Function>tt_feature_required</Function></Term>
  80. <ListItem>
  81. <Para>Declares a feature to be required by the calling code. If the feature is
  82. available, <Function>tt_feature_required</Function> enables it. If the
  83. feature requires the ToolTalk service to perform some initialization
  84. (for example, <systemitem class="constant">TT_FEATURE_MULTITHREADED</systemitem>), the
  85. initialization is performed in this call. Some features (such as
  86. <systemitem class="constant">TT_FEATURE_MULTITHREADED</systemitem>)
  87. require this call to be made before calling
  88. <function>tt_open</function>.
  89. </Para>
  90. </ListItem>
  91. </VarListEntry>
  92. <VarListEntry>
  93. <Term><Function>tt_procid_session</Function></Term>
  94. <ListItem>
  95. <Para>Returns the identifier of the session in which a
  96. specified procid was opened.
  97. </Para>
  98. </ListItem>
  99. </VarListEntry>
  100. <VarListEntry>
  101. <Term><Function>tt_thread_procid</Function></Term>
  102. <ListItem>
  103. <Para>Returns the current default procid for the currently-active thread.
  104. If there is no default procid set for the thread, then the process
  105. default procid is returned.
  106. </Para>
  107. </ListItem>
  108. </VarListEntry>
  109. <VarListEntry>
  110. <Term><Function>tt_thread_procid_set</Function></Term>
  111. <ListItem>
  112. <Para>Sets the default procid for the currently active thread.
  113. The default procid is an implicit argument to most ToolTalk API calls.
  114. </Para>
  115. </ListItem>
  116. </VarListEntry>
  117. <VarListEntry>
  118. <Term><Function>tt_thread_session</Function></Term>
  119. <ListItem>
  120. <Para>Retrieves the default session identifier for the currently active
  121. thread. If there is no default session set for the currently-active
  122. thread, then the process default session identifier is returned.
  123. </Para>
  124. </ListItem>
  125. </VarListEntry>
  126. <VarListEntry>
  127. <Term><Function>tt_thread_session_set</Function></Term>
  128. <ListItem>
  129. <Para>Sets the default session identifier for the currently active thread. The
  130. ToolTalk service uses the initial user session as the default session
  131. and supports one session per procid. The application can make this call
  132. before it calls <function>tt_open</function> to specify which session it
  133. wants to connect to in the active thread.
  134. </Para>
  135. </ListItem>
  136. </VarListEntry>
  137. </VariableList>
  138. <para>Note that since the multithreaded feature may not be available on all
  139. platforms, the <Function>tt_feature_enabled</Function> function is
  140. provided to query for the existence of the feature. The intent is that
  141. even platforms that do not enable the multithreaded feature should
  142. implement the thread-related calls, returning <systemitem class="constant">TT_ERR_UNIMP</systemitem>. This allows a run-time check
  143. without unresolved symbol problems.
  144. </para>
  145. </RefSect1>
  146. <RefSect1>
  147. <Title>SEE ALSO</Title>
  148. <Para>&cdeman.Tt.tt.c.h;,
  149. &cdeman.tt.feature.enabled;,
  150. &cdeman.tt.feature.required;,
  151. &cdeman.tt.procid.session;,
  152. &cdeman.tt.thread.procid;,
  153. &cdeman.tt.thread.procid.set;,
  154. &cdeman.tt.thread.session;,
  155. &cdeman.tt.thread.session;
  156. </para>
  157. </RefSect1>
  158. </RefEntry>