manpagez: man pages & more
info bigloo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

17.3.2 Threads

Bigloo syntax: instantiate::pthread (body thunk) [(name name)]
SRFI-18 function: make-thread thunk [name]

Returns a new thread which is not started yet. The body of the thread is the body of the procedure thunk. The optional argument name can be use to identify the thread. It can be any Bigloo value.

Warning: the make-thread function is deprecated, but still provided for a backward compatibility with previous release of Bigloo. The use of this function is highly discouraged, in favor of the instantiate::pthread form.

(module example
   (library pthread)
   (main main))

(define (main argv)
   (make-thread 
    (lambda () 
       (print 1)
       (thread-yield!)
       (print 2)) 
    'my-thread))
SRFI-18 function: thread-start! thread
SRFI-18 function: thread-start-joinable! thread

Runs a thread created with instantiate::pthread. By default, threads are detached, and thus, they cannot be joined.

SRFI-18 function: thread-yield!

The current thread cooperates.

SRFI-18 function: thread-sleep! timeout

The current thread sleeps for a certain period. It is suspended and the scheduler is free to select a new thread to be resumed. If there is only one thread started in the scheduler, the same thread will be resumed. The time of timeout is used to determine the time the thread must sleep.

Here are the possible types for timeout.

  • date: the thread sleeps at least until the date timeout.
  • real: the thread sleeps at least timeout seconds.
  • fixum, elong, llong: the thread sleeps at least timeout milli-seconds.
SRFI-18 function: thread-terminate! thread

Terminates thread as soon as possible.

SRFI-18 function: thread-join! thread

The current thread waits until the thread terminates. If thread terminates, thread-join! returns the end-result of the thread or the end-exception if that thread terminates abnormally.

It is possible to wait for the termination of the a thread if and only if it has been started with thread-start-joinable!. In particular, threads started with thread-start! cannot be joined.

SRFI-18 function: terminated-thread-exception? obj
SRFI-18 function: uncaught-exception? obj
SRFI-18 function: uncaught-exception-reason exc

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on October 23, 2011 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.