6 /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
8 * This library is free software; you can redistribute it and/or
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.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
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
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include "libguile/__scm.h"
27 #include "libguile/root.h"
28 #include "libguile/threads.h"
32 #define scm_mask_ints (SCM_I_CURRENT_THREAD->block_asyncs != 0)
36 SCM_API
void scm_async_click (void);
37 SCM_API
void scm_switch (void);
38 SCM_API SCM
scm_async (SCM thunk
);
39 SCM_API SCM
scm_async_mark (SCM a
);
40 SCM_API SCM
scm_system_async_mark (SCM a
);
41 SCM_API SCM
scm_system_async_mark_for_thread (SCM a
, SCM thread
);
42 SCM_INTERNAL
void scm_i_queue_async_cell (SCM cell
, scm_i_thread
*);
43 SCM_INTERNAL
int scm_i_setup_sleep (scm_i_thread
*,
44 SCM obj
, scm_i_pthread_mutex_t
*m
,
46 SCM_INTERNAL
void scm_i_reset_sleep (scm_i_thread
*);
47 SCM_API SCM
scm_run_asyncs (SCM list_of_a
);
48 SCM_API SCM
scm_noop (SCM args
);
49 SCM_API SCM
scm_call_with_blocked_asyncs (SCM proc
);
50 SCM_API SCM
scm_call_with_unblocked_asyncs (SCM proc
);
51 void *scm_c_call_with_blocked_asyncs (void *(*p
) (void *d
), void *d
);
52 void *scm_c_call_with_unblocked_asyncs (void *(*p
) (void *d
), void *d
);
53 void scm_dynwind_block_asyncs (void);
54 void scm_dynwind_unblock_asyncs (void);
56 /* Critical sections */
58 /* XXX - every critical section needs to be examined whether the
59 requirements for SCM_CRITICAL_SECTION_START/END are fulfilled. See
63 /* Defined in threads.c. */
64 extern scm_i_pthread_mutex_t scm_i_critical_section_mutex
;
66 #define SCM_CRITICAL_SECTION_START \
68 scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex);\
69 SCM_I_CURRENT_THREAD->block_asyncs++; \
70 SCM_I_CURRENT_THREAD->critical_section_level++; \
72 #define SCM_CRITICAL_SECTION_END \
74 SCM_I_CURRENT_THREAD->critical_section_level--; \
75 SCM_I_CURRENT_THREAD->block_asyncs--; \
76 scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \
80 SCM_INTERNAL
void scm_init_async (void);
82 #if (SCM_ENABLE_DEPRECATED == 1)
84 SCM_DEPRECATED SCM
scm_system_async (SCM thunk
);
85 SCM_DEPRECATED SCM
scm_unmask_signals (void);
86 SCM_DEPRECATED SCM
scm_mask_signals (void);
90 #endif /* SCM_ASYNC_H */