1 /* -*- mode: C -*- */ 2 /* 3 IGraph library. 4 Copyright (C) 2003-2012 Gabor Csardi <csardi.gabor@gmail.com> 5 334 Harvard street, Cambridge, MA 02139 USA 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 02110-1301 USA 21 22 */ 23 24 #ifndef IGRAPH_INTERRUPT_INTERNAL_H 25 #define IGRAPH_INTERRUPT_INTERNAL_H 26 27 #include "igraph_decls.h" 28 #include "igraph_interrupt.h" 29 #include "config.h" 30 31 __BEGIN_DECLS 32 33 extern IGRAPH_THREAD_LOCAL igraph_interruption_handler_t 34 *igraph_i_interruption_handler; 35 36 /** 37 * \define IGRAPH_ALLOW_INTERRUPTION 38 * \brief 39 * 40 * This macro should be called when interruption is allowed. It calls 41 * \ref igraph_allow_interruption() with the proper parameters and if that returns 42 * anything but \c IGRAPH_SUCCESS then 43 * the macro returns the "calling" function as well, with the proper 44 * error code (\c IGRAPH_INTERRUPTED). 45 */ 46 47 #define IGRAPH_ALLOW_INTERRUPTION() \ 48 do { \ 49 if (igraph_i_interruption_handler) { if (igraph_allow_interruption(NULL) != IGRAPH_SUCCESS) return IGRAPH_INTERRUPTED; \ 50 } } while (0) 51 52 #define IGRAPH_ALLOW_INTERRUPTION_NORETURN() \ 53 do { \ 54 if (igraph_i_interruption_handler) { igraph_allow_interruption(NULL); } \ 55 } while (0) 56 57 __END_DECLS 58 59 #endif 60