appc.sgm 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!-- $XConsortium: appc.sgm /main/6 1996/09/08 19:35:15 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. <Title Id="TTUG.ttmt.mkr.1">Writing Thread-Safe ToolTalk Applications</Title>
  10. <indexterm><primary>thread-safe ToolTalk applications</primary><secondary>writing</secondary></indexterm>
  11. <Para>The multithread-safe ToolTalk
  12. library enables application developers to write
  13. multithreaded applications for ToolTalk without having to manage
  14. locks on ToolTalk resources explicitly in their application code.
  15. An extended version of the <Filename>Xthreads.h</Filename> thread API wrappers
  16. is used; therefore, multithreaded libtt should be readily
  17. portable to various thread implementations.
  18. </para>
  19. <para>To protect internal libtt resources, a process-wide lock is introduced and
  20. maintained. Unlike the case of window toolkits, few applications
  21. spend a significant amount of their time in libtt, so the added
  22. parallelism of more fine-grained locking techniques would not
  23. result in a perceptible performance improvement.
  24. </para>
  25. <para>A few ToolTalk global values, such as the default <literal>procid</literal> and the
  26. storage stack manipulated by the <function>tt_mark</function> and <function>tt_release</function> API
  27. calls, must have a consistent state as seen by one thread across
  28. ToolTalk API calls &mdash these values are made into thread-specific data.
  29. Additional API calls are introduced to initialize this behavior
  30. and manipulate the new data. When a thread-specific value has been
  31. set for the current thread, existing API calls are modified
  32. to reference the thread-specific values instead of the
  33. process-wide values. If no thread-specific value
  34. has been set for the current thread, then the process-wide value
  35. is used.
  36. </para>
  37. <para>The multithreaded feature may not be
  38. available on all platforms. For this reason, an API for querying for the
  39. existence of the feature is included in the library. The intent is
  40. that even platforms that do not enable the multithreaded
  41. feature should implement the new API calls, returning
  42. <Symbol>TT_ERR_UNIMP</Symbol> for the thread-specific ones; this
  43. allows application developers to do run-time checks without
  44. having to deal with the problem of unresolved symbols.
  45. </para>
  46. <para>Following is a summary of the API:
  47. </para>
  48. <itemizedlist>
  49. <listitem>
  50. <para><function>tt_feature_enabled</function> &mdash determine whether the specified feature has been enabled.<indexterm><primary>thread-safe ToolTalk applications</primary><secondary>tt_feature_enabled</secondary></indexterm><indexterm><primary>tt_feature_enabled function</primary></indexterm>
  51. </para>
  52. </listitem>
  53. <listitem>
  54. <para><function>tt_feature_required</function> &mdash declare that the specified feature is required, and enable it if it is available.<indexterm><primary>thread-safe ToolTalk applications</primary><secondary>tt_feature_required</secondary></indexterm><indexterm><primary>tt_feature_required function</primary></indexterm>
  55. </para>
  56. </listitem>
  57. <listitem>
  58. <para><function>tt_thread_session_set</function> &mdash set the default session for this thread.<indexterm><primary>thread-safe ToolTalk applications</primary><secondary>tt_thread_session_set</secondary></indexterm><indexterm><primary>tt_thread_session_set function</primary></indexterm>
  59. </para>
  60. </listitem>
  61. <listitem>
  62. <para><function>tt_thread_session</function> &mdash fetch the default session for this thread.<indexterm><primary>thread-safe ToolTalk applications</primary><secondary>tt_thread_session</secondary></indexterm><indexterm><primary>tt_thread_session function</primary></indexterm>
  63. </para>
  64. </listitem>
  65. <listitem>
  66. <para><function>tt_thread_procid_set</function> &mdash set the default process ID for this thread.<indexterm><primary>thread-safe ToolTalk applications</primary><secondary>tt_thread_procid_set</secondary></indexterm><indexterm><primary>tt_thread_procid_set function</primary></indexterm>
  67. </para>
  68. </listitem>
  69. <listitem>
  70. <para><function>tt_procid_session</function> &mdash return the session associated with the specified process ID.<indexterm><primary>thread-safe ToolTalk applications</primary><secondary>tt_procid_session</secondary></indexterm><indexterm><primary>tt_procid_session function</primary></indexterm>
  71. </para>
  72. </listitem>
  73. <listitem>
  74. <para><function>Tttt_c</function> &mdash typedefs and enums.<indexterm><primary>thread-safe ToolTalk applications</primary><secondary>Tttt_c</secondary></indexterm><indexterm><primary>Tttt_c typdef/enum declarations</primary></indexterm>
  75. </para>
  76. </listitem>
  77. </itemizedlist>