futures.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* classes: h_files */
  2. #ifndef SCM_FUTURES_H
  3. #define SCM_FUTURES_H
  4. /* Copyright (C) 2002, 2003, 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. #if 0
  21. /* Futures have the following known bugs, which should be fixed before
  22. including them in Guile:
  23. - The implementation of the thread cache needs to be better so that
  24. it behaves reasonable under heavy use.
  25. - The dynamic state of a thread needs to be properly initialized
  26. when it is retrieved from the cache.
  27. */
  28. #include "libguile/__scm.h"
  29. #include "libguile/threads.h"
  30. typedef struct scm_t_future {
  31. SCM data;
  32. scm_i_pthread_mutex_t mutex;
  33. scm_i_pthread_cond_t cond;
  34. int status;
  35. int die_p;
  36. } scm_t_future;
  37. #define SCM_FUTURE_DEAD 0
  38. #define SCM_FUTURE_SIGNAL_ME -1
  39. #define SCM_FUTURE_COMPUTING 1
  40. #define SCM_FUTURE_TASK_ASSIGNED 2
  41. #define SCM_VALIDATE_FUTURE(pos, obj) \
  42. SCM_ASSERT_TYPE (SCM_TYP16_PREDICATE (scm_tc16_future, obj), \
  43. obj, pos, FUNC_NAME, "future");
  44. #define SCM_FUTURE(future) ((scm_t_future *) SCM_SMOB_DATA_2 (future))
  45. #define SCM_FUTURE_MUTEX(future) (&SCM_FUTURE (future)->mutex)
  46. #define SCM_FUTURE_COND(future) (&SCM_FUTURE (future)->cond)
  47. #define SCM_FUTURE_STATUS(future) (SCM_FUTURE (future)->status)
  48. #define SCM_SET_FUTURE_STATUS(future, x) \
  49. do { SCM_FUTURE (future)->status = (x); } while (0)
  50. #define SCM_FUTURE_ALIVE_P(future) (SCM_FUTURE_STATUS (future))
  51. #define SCM_FUTURE_DATA(future) (SCM_FUTURE (future)->data)
  52. #define SCM_SET_FUTURE_DATA(future, x) \
  53. do { SCM_FUTURE (future)->data = (x); } while (0)
  54. #define SCM_FUTURE_NEXT SCM_SMOB_OBJECT
  55. #define SCM_FUTURE_NEXTLOC SCM_SMOB_OBJECT_LOC
  56. #define SCM_SET_FUTURE_NEXT SCM_SET_SMOB_OBJECT
  57. SCM_API scm_t_bits scm_tc16_future;
  58. extern SCM *scm_loc_sys_thread_handler;
  59. SCM_API SCM scm_i_make_future (SCM thunk);
  60. SCM_API SCM scm_make_future (SCM thunk);
  61. SCM_API SCM scm_future_ref (SCM future);
  62. void scm_init_futures (void);
  63. #endif /* Futures are disabled for now. */
  64. #endif /* SCM_FUTURES_H */
  65. /*
  66. Local Variables:
  67. c-file-style: "gnu"
  68. End:
  69. */