home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / Python / thread_foobar.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-25  |  2.5 KB  |  150 lines

  1.  
  2. /*
  3.  * Initialization.
  4.  */
  5. static void
  6. PyThread__init_thread(void)
  7. {
  8. }
  9.  
  10. /*
  11.  * Thread support.
  12.  */
  13. int
  14. PyThread_start_new_thread(void (*func)(void *), void *arg)
  15. {
  16.     int success = 0;    /* init not needed when SOLARIS_THREADS and */
  17.                 /* C_THREADS implemented properly */
  18.  
  19.     dprintf(("PyThread_start_new_thread called\n"));
  20.     if (!initialized)
  21.         PyThread_init_thread();
  22.     return success < 0 ? 0 : 1;
  23. }
  24.  
  25. long
  26. PyThread_get_thread_ident(void)
  27. {
  28.     if (!initialized)
  29.         PyThread_init_thread();
  30. }
  31.  
  32. static
  33. void do_PyThread_exit_thread(int no_cleanup)
  34. {
  35.     dprintf(("PyThread_exit_thread called\n"));
  36.     if (!initialized)
  37.         if (no_cleanup)
  38.             _exit(0);
  39.         else
  40.             exit(0);
  41. }
  42.  
  43. void
  44. PyThread_exit_thread(void)
  45. {
  46.     do_PyThread_exit_thread(0);
  47. }
  48.  
  49. void
  50. PyThread__exit_thread(void)
  51. {
  52.     do_PyThread_exit_thread(1);
  53. }
  54.  
  55. #ifndef NO_EXIT_PROG
  56. static
  57. void do_PyThread_exit_prog(int status, int no_cleanup)
  58. {
  59.     dprintf(("PyThread_exit_prog(%d) called\n", status));
  60.     if (!initialized)
  61.         if (no_cleanup)
  62.             _exit(status);
  63.         else
  64.             exit(status);
  65. }
  66.  
  67. void
  68. PyThread_exit_prog(int status)
  69. {
  70.     do_PyThread_exit_prog(status, 0);
  71. }
  72.  
  73. void
  74. PyThread__exit_prog(int status)
  75. {
  76.     do_PyThread_exit_prog(status, 1);
  77. }
  78. #endif /* NO_EXIT_PROG */
  79.  
  80. /*
  81.  * Lock support.
  82.  */
  83. PyThread_type_lock
  84. PyThread_allocate_lock(void)
  85. {
  86.  
  87.     dprintf(("PyThread_allocate_lock called\n"));
  88.     if (!initialized)
  89.         PyThread_init_thread();
  90.  
  91.     dprintf(("PyThread_allocate_lock() -> %p\n", lock));
  92.     return (PyThread_type_lock) lock;
  93. }
  94.  
  95. void
  96. PyThread_free_lock(PyThread_type_lock lock)
  97. {
  98.     dprintf(("PyThread_free_lock(%p) called\n", lock));
  99. }
  100.  
  101. int
  102. PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
  103. {
  104.     int success;
  105.  
  106.     dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
  107.     dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
  108.     return success;
  109. }
  110.  
  111. void
  112. PyThread_release_lock(PyThread_type_lock lock)
  113. {
  114.     dprintf(("PyThread_release_lock(%p) called\n", lock));
  115. }
  116.  
  117. /*
  118.  * Semaphore support.
  119.  */
  120. PyThread_type_sema
  121. PyThread_allocate_sema(int value)
  122. {
  123.     dprintf(("PyThread_allocate_sema called\n"));
  124.     if (!initialized)
  125.         PyThread_init_thread();
  126.  
  127.     dprintf(("PyThread_allocate_sema() -> %p\n",  sema));
  128.     return (PyThread_type_sema) sema;
  129. }
  130.  
  131. void
  132. PyThread_free_sema(PyThread_type_sema sema)
  133. {
  134.     dprintf(("PyThread_free_sema(%p) called\n",  sema));
  135. }
  136.  
  137. int
  138. PyThread_down_sema(PyThread_type_sema sema, int waitflag)
  139. {
  140.     dprintf(("PyThread_down_sema(%p, %d) called\n",  sema, waitflag));
  141.     dprintf(("PyThread_down_sema(%p) return\n",  sema));
  142.     return -1;
  143. }
  144.  
  145. void
  146. PyThread_up_sema(PyThread_type_sema sema)
  147. {
  148.     dprintf(("PyThread_up_sema(%p)\n",  sema));
  149. }
  150.