home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Musik / Misc / Amster / Source / include / thread.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-01  |  1.1 KB  |  61 lines

  1. /*
  2. ** Thread Header
  3. */
  4.  
  5. #include <sys/types.h>
  6.  
  7. #include <exec/ports.h>
  8. #include <exec/tasks.h>
  9.  
  10. #ifndef AMSTER_THREAD_H
  11. #define AMSTER_THREAD_H
  12.  
  13. extern u_long th_sigmask;
  14.  
  15. typedef void (*thcb)(struct thread_struct *t, int com, APTR data);
  16.  
  17. typedef struct thmsg_struct
  18. {
  19.     struct Message header;
  20.     struct thread_struct *sender;
  21.     int com;
  22.     APTR data;
  23.     int isreply;
  24. } *thmsg, _thmsg;
  25.  
  26. typedef struct thread_struct
  27. {
  28.     struct thread_struct *next;
  29.     struct Task *task;
  30.     struct MsgPort *port;
  31.     struct MsgPort *mother;
  32.     struct Task *mother_task;
  33.     thcb handler;
  34.     APTR data;
  35.     _thmsg sm;
  36.     _thmsg em;
  37. } *thread, _thread;
  38.  
  39. enum thread_state {
  40.     THC_STARTUP = -1,
  41.     THC_EXIT = -2,
  42.     THC_FINISH = -3
  43. };
  44.  
  45.  
  46. extern int th_init(void);
  47. extern void th_exit(void);
  48.  
  49. extern thread th_spawn(thcb handler, char *name, void (*func)(void), int pri, APTR data);
  50. extern void th_message(thread t, int com, APTR data);
  51. extern void th_poll(void);
  52.  
  53. /* following functions are called from threads */
  54. extern thread thr_init(void);
  55. extern void thr_exit(thread t, int reason);
  56. extern void thr_message(thread t, int com, APTR data);
  57.  
  58.  
  59.  
  60. #endif    /* AMSTER_THREAD_H */
  61.