This commit is contained in:
Michiel Borkent 2023-03-08 10:55:43 +01:00
parent 84bd66f869
commit 68878e7f89
3 changed files with 10 additions and 2 deletions

View file

@ -10,6 +10,7 @@ A preview of the next release can be installed from
## Unreleased
- [#1507](https://github.com/babashka/babashka/issues/1507): Expose methods on java.lang.VirtualThread ([@lispyclouds](https://github.com/lispyclouds))
- [#1510](https://github.com/babashka/babashka/issues/1510): add virtual thread interop on `Thread`
## 1.2.174 (2023-03-01)

View file

@ -55,7 +55,9 @@
{:name "start"}
{:name "toString"}
{:name "yield"}
~@(when has-of-virtual? [{:name "ofVirtual"}])]}
~@(when has-of-virtual? [{:name "ofVirtual"}
{:name "startVirtualThread"}
{:name "isVirtual"}])]}
java.net.URL
{:allPublicConstructors true
:allPublicFields true

View file

@ -13,4 +13,9 @@
(deftest vthreads-test
(testing "can invoke methods on java.lang.VirtualThread"
(is (= "" (bb nil "(set-agent-send-off-executor! (java.util.concurrent.Executors/newVirtualThreadPerTaskExecutor)) @(future (.getName (Thread/currentThread)))")))))
(is (= "" (bb nil "(set-agent-send-off-executor! (java.util.concurrent.Executors/newVirtualThreadPerTaskExecutor)) @(future (.getName (Thread/currentThread)))"))))
(is (= [false true]
(bb nil (pr-str '(do
(def t (Thread. (fn [])))
(def vt (Thread/startVirtualThread (fn [])))
[(.isVirtual t) (.isVirtual vt)]))))))