Skip to content

Commit 053c2c5

Browse files
authored
use parallel thread for heavy tasks in 9.0+ (#171)
1 parent c187aba commit 053c2c5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

scheduler.rkt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#lang racket/base
22

33
(require racket/async-channel
4-
racket/match)
4+
racket/match
5+
"version.rkt")
56

67
;; Scheduler manages a list of asynchronous and cancellable tasks for each document.
78
;; For each document, a task is uniquely identified by its key.
@@ -24,7 +25,10 @@
2425
(define th (hash-ref doc type))
2526
(unless (thread-dead? th)
2627
(kill-thread th)))
27-
(hash-set! doc type (thread task)))))
28+
(hash-set! doc type
29+
(if (version>=9.0?)
30+
(thread #:pool 'own task)
31+
(thread task))))))
2832
(loop)))
2933

3034
(define _scheduler (thread schedule))

version.rkt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#lang racket
2+
3+
(provide version>=9.0?)
4+
5+
(require version/utils)
6+
7+
(define (version>=? target-version)
8+
(not (version<? (version) target-version)))
9+
10+
(define (version>=9.0?)
11+
(version>=? "9.0"))
12+

0 commit comments

Comments
 (0)