home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _fa49bc9ab5ee740013af984bb8149c17 < prev    next >
Text File  |  2004-06-01  |  2KB  |  66 lines

  1. /*    fakethr.h
  2.  *
  3.  *    Copyright (C) 1999, by Larry Wall and others
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  */
  9.  
  10. typedef int perl_mutex;
  11. typedef int perl_key;
  12.  
  13. typedef struct perl_thread *perl_os_thread;
  14. /* With fake threads, thr is global(ish) so we don't need dTHR */
  15. #define dTHR extern int errno
  16.  
  17. struct perl_wait_queue {
  18.     struct perl_thread *    thread;
  19.     struct perl_wait_queue *    next;
  20. };
  21. typedef struct perl_wait_queue *perl_cond;
  22.  
  23. /* Ask thread.h to include our per-thread extras */
  24. #define HAVE_THREAD_INTERN
  25. struct thread_intern {
  26.     perl_os_thread next_run, prev_run;  /* Linked list of runnable threads */
  27.     perl_cond   wait_queue;             /* Wait queue that we are waiting on */
  28.     IV          private;                /* Holds data across time slices */
  29.     I32         savemark;               /* Holds MARK for thread join values */
  30. };
  31.  
  32. #define init_thread_intern(t)                 \
  33.     STMT_START {                    \
  34.     t->self = (t);                    \
  35.     (t)->i.next_run = (t)->i.prev_run = (t);    \
  36.     (t)->i.wait_queue = 0;                \
  37.     (t)->i.private = 0;                \
  38.     } STMT_END
  39.  
  40. /*
  41.  * Note that SCHEDULE() is only callable from pp code (which
  42.  * must be expecting to be restarted). We'll have to do
  43.  * something a bit different for XS code.
  44.  */
  45.  
  46. #define SCHEDULE() return schedule(), PL_op
  47.  
  48. #define MUTEX_LOCK(m)
  49. #define MUTEX_UNLOCK(m)
  50. #define MUTEX_INIT(m)
  51. #define MUTEX_DESTROY(m)
  52. #define COND_INIT(c) perl_cond_init(c)
  53. #define COND_SIGNAL(c) perl_cond_signal(c)
  54. #define COND_BROADCAST(c) perl_cond_broadcast(c)
  55. #define COND_WAIT(c, m)        \
  56.     STMT_START {        \
  57.     perl_cond_wait(c);    \
  58.     SCHEDULE();        \
  59.     } STMT_END
  60. #define COND_DESTROY(c)
  61.  
  62. #define THREAD_CREATE(t, f)    f((t))
  63. #define THREAD_POST_CREATE(t)    NOOP
  64.  
  65. #define YIELD    NOOP
  66.