Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
82893676 MG |
3 | #ifndef SCM_ASYNC_H |
4 | #define SCM_ASYNC_H | |
0527e687 | 5 | |
0eb934f1 | 6 | /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc. |
843e4e9d | 7 | * |
73be1d9e | 8 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
9 | * modify it under the terms of the GNU Lesser General Public License |
10 | * as published by the Free Software Foundation; either version 3 of | |
11 | * the License, or (at your option) any later version. | |
843e4e9d | 12 | * |
53befeb7 NJ |
13 | * This library is distributed in the hope that it will be useful, but |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
843e4e9d | 17 | * |
73be1d9e MV |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software | |
53befeb7 NJ |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
21 | * 02110-1301 USA | |
73be1d9e | 22 | */ |
d3a6bc94 | 23 | |
0f2d19dd JB |
24 | \f |
25 | ||
b4309c3c | 26 | #include "libguile/__scm.h" |
5b900ecf | 27 | #include "libguile/root.h" |
9de87eea | 28 | #include "libguile/threads.h" |
0f2d19dd | 29 | |
0f2d19dd JB |
30 | \f |
31 | ||
e4e93373 MV |
32 | SCM_API void scm_async_click (void); |
33 | SCM_API void scm_switch (void); | |
34 | SCM_API SCM scm_async (SCM thunk); | |
e4e93373 MV |
35 | SCM_API SCM scm_async_mark (SCM a); |
36 | SCM_API SCM scm_system_async_mark (SCM a); | |
61c95a49 | 37 | SCM_API SCM scm_system_async_mark_for_thread (SCM a, SCM thread); |
102dbb6f LC |
38 | SCM_INTERNAL void scm_i_queue_async_cell (SCM cell, scm_i_thread *); |
39 | SCM_INTERNAL int scm_i_setup_sleep (scm_i_thread *, | |
40 | SCM obj, scm_i_pthread_mutex_t *m, | |
41 | int fd); | |
42 | SCM_INTERNAL void scm_i_reset_sleep (scm_i_thread *); | |
e4e93373 MV |
43 | SCM_API SCM scm_run_asyncs (SCM list_of_a); |
44 | SCM_API SCM scm_noop (SCM args); | |
e292f7aa MV |
45 | SCM_API SCM scm_call_with_blocked_asyncs (SCM proc); |
46 | SCM_API SCM scm_call_with_unblocked_asyncs (SCM proc); | |
47 | void *scm_c_call_with_blocked_asyncs (void *(*p) (void *d), void *d); | |
48 | void *scm_c_call_with_unblocked_asyncs (void *(*p) (void *d), void *d); | |
661ae7ab MV |
49 | void scm_dynwind_block_asyncs (void); |
50 | void scm_dynwind_unblock_asyncs (void); | |
9de87eea | 51 | |
a4d106c7 MV |
52 | /* Critical sections */ |
53 | ||
54 | /* XXX - every critical section needs to be examined whether the | |
55 | requirements for SCM_CRITICAL_SECTION_START/END are fulfilled. See | |
56 | the manual. | |
57 | */ | |
58 | ||
87f30eda | 59 | /* Defined in threads.c. */ |
46935a1f | 60 | SCM_INTERNAL scm_i_pthread_mutex_t scm_i_critical_section_mutex; |
a4d106c7 | 61 | |
46935a1f LC |
62 | SCM_API void scm_critical_section_start (void); |
63 | SCM_API void scm_critical_section_end (void); | |
64 | ||
65 | #ifdef BUILDING_LIBGUILE | |
66 | ||
67 | # define SCM_CRITICAL_SECTION_START \ | |
68 | do { \ | |
69 | scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex); \ | |
70 | SCM_I_CURRENT_THREAD->block_asyncs++; \ | |
71 | SCM_I_CURRENT_THREAD->critical_section_level++; \ | |
a4d106c7 | 72 | } while (0) |
46935a1f LC |
73 | # define SCM_CRITICAL_SECTION_END \ |
74 | do { \ | |
75 | SCM_I_CURRENT_THREAD->critical_section_level--; \ | |
76 | SCM_I_CURRENT_THREAD->block_asyncs--; \ | |
a4d106c7 | 77 | scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \ |
46935a1f | 78 | scm_async_click (); \ |
a4d106c7 MV |
79 | } while (0) |
80 | ||
46935a1f LC |
81 | #else /* !BUILDING_LIBGUILE */ |
82 | ||
83 | # define SCM_CRITICAL_SECTION_START scm_critical_section_start () | |
84 | # define SCM_CRITICAL_SECTION_END scm_critical_section_end () | |
85 | ||
86 | #endif /* !BUILDING_LIBGUILE */ | |
87 | ||
102dbb6f | 88 | SCM_INTERNAL void scm_init_async (void); |
e292f7aa | 89 | |
e71a8bf2 | 90 | #if (SCM_ENABLE_DEPRECATED == 1) |
e292f7aa | 91 | |
0eb934f1 LC |
92 | SCM_DEPRECATED SCM scm_system_async (SCM thunk); |
93 | SCM_DEPRECATED SCM scm_unmask_signals (void); | |
94 | SCM_DEPRECATED SCM scm_mask_signals (void); | |
e292f7aa MV |
95 | |
96 | #endif | |
0f2d19dd | 97 | |
82893676 | 98 | #endif /* SCM_ASYNC_H */ |
89e00824 ML |
99 | |
100 | /* | |
101 | Local Variables: | |
102 | c-file-style: "gnu" | |
103 | End: | |
104 | */ |