async.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* classes: h_files */
  2. #ifndef SCM_ASYNC_H
  3. #define SCM_ASYNC_H
  4. /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "libguile/__scm.h"
  21. #include "libguile/root.h"
  22. #include "libguile/threads.h"
  23. #define scm_mask_ints (SCM_I_CURRENT_THREAD->block_asyncs != 0)
  24. SCM_API void scm_async_click (void);
  25. SCM_API void scm_switch (void);
  26. SCM_API SCM scm_async (SCM thunk);
  27. SCM_API SCM scm_async_mark (SCM a);
  28. SCM_API SCM scm_system_async_mark (SCM a);
  29. SCM_API SCM scm_system_async_mark_for_thread (SCM a, SCM thread);
  30. SCM_API void scm_i_queue_async_cell (SCM cell, scm_i_thread *);
  31. SCM_API int scm_i_setup_sleep (scm_i_thread *,
  32. SCM obj, scm_i_pthread_mutex_t *m, int fd);
  33. SCM_API void scm_i_reset_sleep (scm_i_thread *);
  34. SCM_API SCM scm_run_asyncs (SCM list_of_a);
  35. SCM_API SCM scm_noop (SCM args);
  36. SCM_API SCM scm_call_with_blocked_asyncs (SCM proc);
  37. SCM_API SCM scm_call_with_unblocked_asyncs (SCM proc);
  38. void *scm_c_call_with_blocked_asyncs (void *(*p) (void *d), void *d);
  39. void *scm_c_call_with_unblocked_asyncs (void *(*p) (void *d), void *d);
  40. void scm_dynwind_block_asyncs (void);
  41. void scm_dynwind_unblock_asyncs (void);
  42. /* Critical sections */
  43. /* XXX - every critical section needs to be examined whether the
  44. requirements for SCM_CRITICAL_SECTION_START/END are fulfilled. See
  45. the manual.
  46. */
  47. /* Defined in threads.c. */
  48. extern scm_i_pthread_mutex_t scm_i_critical_section_mutex;
  49. #define SCM_CRITICAL_SECTION_START \
  50. do { \
  51. scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex);\
  52. SCM_I_CURRENT_THREAD->block_asyncs++; \
  53. SCM_I_CURRENT_THREAD->critical_section_level++; \
  54. } while (0)
  55. #define SCM_CRITICAL_SECTION_END \
  56. do { \
  57. SCM_I_CURRENT_THREAD->critical_section_level--; \
  58. SCM_I_CURRENT_THREAD->block_asyncs--; \
  59. scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \
  60. scm_async_click (); \
  61. } while (0)
  62. SCM_API void scm_init_async (void);
  63. #if (SCM_ENABLE_DEPRECATED == 1)
  64. SCM_API SCM scm_system_async (SCM thunk);
  65. SCM_API SCM scm_unmask_signals (void);
  66. SCM_API SCM scm_mask_signals (void);
  67. #endif
  68. #endif /* SCM_ASYNC_H */
  69. /*
  70. Local Variables:
  71. c-file-style: "gnu"
  72. End:
  73. */