os0thread.h
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:4k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /******************************************************
  2. The interface to the operating system
  3. process and thread control primitives
  4. (c) 1995 Innobase Oy
  5. Created 9/8/1995 Heikki Tuuri
  6. *******************************************************/
  7. #ifndef os0thread_h
  8. #define os0thread_h
  9. #include "univ.i"
  10. /* Maximum number of threads which can be created in the program */
  11. #define OS_THREAD_MAX_N 1000
  12. /* Possible fixed priorities for threads */
  13. #define OS_THREAD_PRIORITY_NONE 100
  14. #define OS_THREAD_PRIORITY_BACKGROUND 1
  15. #define OS_THREAD_PRIORITY_NORMAL 2
  16. #define OS_THREAD_PRIORITY_ABOVE_NORMAL 3
  17. #ifdef __WIN__
  18. typedef void* os_thread_t;
  19. #else
  20. typedef pthread_t               os_thread_t;
  21. #endif
  22. typedef unsigned long int os_thread_id_t;
  23. /* Define a function pointer type to use in a typecast */
  24. typedef void* (*os_posix_f_t) (void*);
  25. /********************************************************************
  26. Creates a new thread of execution. The execution starts from
  27. the function given. The start function takes a void* parameter
  28. and returns a ulint. */
  29. os_thread_t
  30. os_thread_create(
  31. /*=============*/
  32. /* out: handle to the thread */
  33. #ifndef __WIN__
  34.  os_posix_f_t            start_f,
  35. #else
  36. ulint (*start_f)(void*), /* in: pointer to function
  37. from which to start */
  38. #endif
  39. void* arg, /* in: argument to start
  40. function */
  41. os_thread_id_t* thread_id); /* out: id of created
  42. thread */
  43. /*********************************************************************
  44. A thread calling this function ends its execution. */
  45. void
  46. os_thread_exit(
  47. /*===========*/
  48. ulint code); /* in: exit code */
  49. /*********************************************************************
  50. Returns the thread identifier of current thread. */
  51. os_thread_id_t
  52. os_thread_get_curr_id(void);
  53. /*========================*/
  54. /*********************************************************************
  55. Returns handle to the current thread. */
  56. os_thread_t
  57. os_thread_get_curr(void);
  58. /*====================*/
  59. /*********************************************************************
  60. Converts a thread id to a ulint. */
  61. ulint
  62. os_thread_conv_id_to_ulint(
  63. /*=======================*/
  64. /* out: converted to ulint */
  65. os_thread_id_t id); /* in: thread id */
  66. /*********************************************************************
  67. Waits for a thread to terminate. */
  68. void
  69. os_thread_wait(
  70. /*===========*/
  71. os_thread_t thread); /* in: thread to wait */
  72. /*********************************************************************
  73. Advises the os to give up remainder of the thread's time slice. */
  74. void
  75. os_thread_yield(void);
  76. /*=================*/
  77. /*********************************************************************
  78. The thread sleeps at least the time given in microseconds. */
  79. void
  80. os_thread_sleep(
  81. /*============*/
  82. ulint tm); /* in: time in microseconds */
  83. /**********************************************************************
  84. Gets a thread priority. */
  85. ulint
  86. os_thread_get_priority(
  87. /*===================*/
  88. /* out: priority */
  89. os_thread_t handle);/* in: OS handle to the thread */
  90. /**********************************************************************
  91. Sets a thread priority. */
  92. void
  93. os_thread_set_priority(
  94. /*===================*/
  95. os_thread_t handle, /* in: OS handle to the thread */
  96. ulint pri); /* in: priority: one of OS_PRIORITY_... */
  97. /**********************************************************************
  98. Gets the last operating system error code for the calling thread. */
  99. ulint
  100. os_thread_get_last_error(void);
  101. /*==========================*/
  102. #ifndef UNIV_NONINL
  103. #include "os0thread.ic"
  104. #endif
  105. #endif