gate.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Thread profiling.
  2. */
  3. /*
  4. This file is part of VIPS.
  5. VIPS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. */
  18. /*
  19. These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
  20. */
  21. #ifndef VIPS_GATE_H
  22. #define VIPS_GATE_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /*__cplusplus*/
  26. #include <vips/vips.h>
  27. #define VIPS_GATE_START( NAME ) \
  28. G_STMT_START { \
  29. if( vips__thread_profile ) \
  30. vips__thread_gate_start( NAME ); \
  31. } G_STMT_END
  32. #define VIPS_GATE_STOP( NAME ) \
  33. G_STMT_START { \
  34. if( vips__thread_profile ) \
  35. vips__thread_gate_stop( NAME ); \
  36. } G_STMT_END
  37. #define VIPS_GATE_MALLOC( SIZE ) \
  38. G_STMT_START { \
  39. if( vips__thread_profile ) \
  40. vips__thread_malloc_free( (gint64) (SIZE) ); \
  41. } G_STMT_END
  42. #define VIPS_GATE_FREE( SIZE ) \
  43. G_STMT_START { \
  44. if( vips__thread_profile ) \
  45. vips__thread_malloc_free( -((gint64) (SIZE)) ); \
  46. } G_STMT_END
  47. extern gboolean vips__thread_profile;
  48. void vips_profile_set( gboolean profile );
  49. void vips__thread_profile_attach( const char *thread_name );
  50. void vips__thread_profile_detach( void );
  51. void vips__thread_profile_stop( void );
  52. void vips__thread_gate_start( const char *gate_name );
  53. void vips__thread_gate_stop( const char *gate_name );
  54. void vips__thread_malloc_free( gint64 size );
  55. #endif /*VIPS_GATE_H*/
  56. #ifdef __cplusplus
  57. }
  58. #endif /*__cplusplus*/