Changeset 21008 in project


Ignore:
Timestamp:
10/25/10 04:03:49 (11 years ago)
Author:
Kon Lovett
Message:

Release.

Location:
release/4/thread-utils
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/thread-utils/tags/1.0.0/thread-reaper.scm

    r20953 r21008  
    9494(define-constant DEFAULT-REAPER-QUANTUM 2500)
    9595(define-constant STOPPING-REAPER-QUANTUM 10000)
    96 (define-constant DEFAULT-REAPER-TIMEOUT 5.0)
     96(define-constant DEFAULT-REAPER-TIMEOUT #f)
    9797(define-constant STOPPING-REAPER-TIMEOUT 1.0)
    9898(define-constant DEFAULT-REAPER-RETRIES 1)
  • release/4/thread-utils/tags/1.0.0/thread-utils.scm

    r20953 r21008  
    4141    (only srfi-18
    4242      thread-state thread? current-thread
     43      condition-variable?
     44      mutex?
    4345      time? seconds->time time->seconds current-time)
    4446    (only type-checks define-check+error-type))
     
    9698(define (*thread-recipients th) (##sys#slot th 12))
    9799
     100;;
     101
     102#; ;accurate and precise but more work
     103(define (block-object-of-recipient? th)
     104  (any
     105    (lambda (rth) (eq? (*thread-block-object rth) th))
     106    (*thread-recipients th)) )
     107
    98108;;;
    99109
     
    119129;;
    120130
     131(define (*thread-blocked?/object th)
     132  (and (thread-blocked? th)
     133       (*thread-block-object th)) )
     134
    121135(define (thread-blocked?/termination th)
    122136  (and (thread-blocked? th)
     137       ;FIXME accurate but imprecise
    123138       (*thread-recipients th)
    124        #t ) )
    125 
    126 (define (thread-blocked?/io th)
    127   (and (thread-blocked? th)
    128        (*thread-block-object th)
    129139       #t ) )
    130140
     
    135145       #t ) )
    136146
     147(define (thread-blocked?/io th)
     148  (and-let* ((obj (*thread-blocked?/object th)))
     149    ;FIXME should check for (fd . i/o)
     150    (pair? obj) ) )
     151
     152;thread-block-object:
     153;- mutex : means owns the mutex (but obviously not blocking on it)
     154;condition-variable : means blocked waiting for a cv announce
     155;thread : means blocked waiting for termination of the thread
     156
    137157;;
    138158
    139159(define (thread-unblock! th)
     160  (when (thread-blocked?/timeout th) (##sys#thread-unblock! th))
     161  #;
    140162  (when (thread-obstructed? th)
    141163    (cond
    142       ((*thread-recipients th)    )  ;cannot unblock when terminating
    143       ((*thread-block-object th)  )  ;cannot unblock when waiting for i/o
    144       ((*thread-block-timeout th) (##sys#thread-unblock! th) ) ) ) )
     164      ((*thread-block-timeout th) (##sys#thread-unblock! th) )
     165      ;cannot unblock when terminating
     166      ((*thread-recipients th)    )
     167      ;cannot unblock when waiting for some other object
     168      ((*thread-block-object th)  ) ) ) )
    145169
    146170) ;module thread-utils
  • release/4/thread-utils/trunk/thread-reaper.scm

    r20953 r21008  
    9494(define-constant DEFAULT-REAPER-QUANTUM 2500)
    9595(define-constant STOPPING-REAPER-QUANTUM 10000)
    96 (define-constant DEFAULT-REAPER-TIMEOUT 5.0)
     96(define-constant DEFAULT-REAPER-TIMEOUT #f)
    9797(define-constant STOPPING-REAPER-TIMEOUT 1.0)
    9898(define-constant DEFAULT-REAPER-RETRIES 1)
  • release/4/thread-utils/trunk/thread-utils.scm

    r20953 r21008  
    4141    (only srfi-18
    4242      thread-state thread? current-thread
     43      condition-variable?
     44      mutex?
    4345      time? seconds->time time->seconds current-time)
    4446    (only type-checks define-check+error-type))
     
    9698(define (*thread-recipients th) (##sys#slot th 12))
    9799
     100;;
     101
     102#; ;accurate and precise but more work
     103(define (block-object-of-recipient? th)
     104  (any
     105    (lambda (rth) (eq? (*thread-block-object rth) th))
     106    (*thread-recipients th)) )
     107
    98108;;;
    99109
     
    119129;;
    120130
     131(define (*thread-blocked?/object th)
     132  (and (thread-blocked? th)
     133       (*thread-block-object th)) )
     134
    121135(define (thread-blocked?/termination th)
    122136  (and (thread-blocked? th)
     137       ;FIXME accurate but imprecise
    123138       (*thread-recipients th)
    124        #t ) )
    125 
    126 (define (thread-blocked?/io th)
    127   (and (thread-blocked? th)
    128        (*thread-block-object th)
    129139       #t ) )
    130140
     
    135145       #t ) )
    136146
     147(define (thread-blocked?/io th)
     148  (and-let* ((obj (*thread-blocked?/object th)))
     149    ;FIXME should check for (fd . i/o)
     150    (pair? obj) ) )
     151
     152;thread-block-object:
     153;- mutex : means owns the mutex (but obviously not blocking on it)
     154;condition-variable : means blocked waiting for a cv announce
     155;thread : means blocked waiting for termination of the thread
     156
    137157;;
    138158
    139159(define (thread-unblock! th)
     160  (when (thread-blocked?/timeout th) (##sys#thread-unblock! th))
     161  #;
    140162  (when (thread-obstructed? th)
    141163    (cond
    142       ((*thread-recipients th)    )  ;cannot unblock when terminating
    143       ((*thread-block-object th)  )  ;cannot unblock when waiting for i/o
    144       ((*thread-block-timeout th) (##sys#thread-unblock! th) ) ) ) )
     164      ((*thread-block-timeout th) (##sys#thread-unblock! th) )
     165      ;cannot unblock when terminating
     166      ((*thread-recipients th)    )
     167      ;cannot unblock when waiting for some other object
     168      ((*thread-block-object th)  ) ) ) )
    145169
    146170) ;module thread-utils
Note: See TracChangeset for help on using the changeset viewer.