basic.texi 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. @node Basic thread operations
  2. @section Basic thread operations
  3. @stindex threads
  4. This section describes the @code{threads} structure.
  5. @cindex spawning threads
  6. @cindex threads, spawning
  7. @deffn procedure spawn thunk [name] @returns{} thread
  8. @code{Spawn} constructs a new thread and instructs the current thread
  9. scheduler to commence running the new thread. @var{Name}, if present,
  10. is used for debugging. The new thread has a fresh
  11. @embedref{Fluid/dynamic bindings, dynamic environment}.
  12. @end deffn
  13. There are several miscellaneous facilities for thread operations.
  14. @cindex yielding threads
  15. @cindex thread yielding
  16. @cindex sleeping threads
  17. @cindex thread sleeping
  18. @deffn procedure relinquish-timeslice @returns{} unspecified
  19. @deffnx procedure sleep count @returns{} unspecified
  20. @code{Relinquish-timeslice} relinquishes the remaining quantum that the
  21. current thread has to run; this allows the current scheduler run the
  22. next thread immediately. @code{Sleep} suspends the current thread for
  23. @var{count} milliseconds.
  24. @end deffn
  25. @cindex thread termination
  26. @cindex terminating threads
  27. @deffn procedure terminate-current-thread @returns{} (does not return)
  28. Terminates the current thread, running all @code{dynamic-wind} exit
  29. points. @code{Terminate-current-thread} obviously does not return.
  30. @end deffn
  31. @cindex thread descriptors
  32. Threads may be represented and manipulated in first-class thread
  33. descriptor objects.
  34. @deffn procedure current-thread @returns{} thread
  35. @deffnx procedure thread? object @returns{} boolean
  36. @deffnx procedure thread-name thread @returns{} value
  37. @deffnx procedure thread-uid thread @returns{} unique-integer-id
  38. @code{Current-thread} returns the thread descriptor for the currently
  39. running thread. @code{Thread?} is the thread descriptor disjoint type
  40. predicate. @code{Thread-name} returns the name that was passed to
  41. @code{spawn} when spawning @var{thread}, or @code{#f} if no name was
  42. passed. @code{Thread-uid} returns a thread descriptor's unique integer
  43. identifier, assigned by the thread system.
  44. @end deffn