equal
deleted
inserted
replaced
24 thread.setDaemon(daemon) |
24 thread.setDaemon(daemon) |
25 thread.start |
25 thread.start |
26 thread |
26 thread |
27 } |
27 } |
28 |
28 |
29 def fork(body: => Unit): Thread = fork()(body) |
|
30 |
|
31 |
29 |
32 /* future result via thread */ |
30 /* future result via thread */ |
33 |
31 |
34 def future[A](name: String = "", daemon: Boolean = false)(body: => A): Future[A] = |
32 def future[A](name: String = "", daemon: Boolean = false)(body: => A): Future[A] = |
35 { |
33 { |
36 val result = Future.promise[A] |
34 val result = Future.promise[A] |
37 fork(name, daemon) { result.fulfill_result(Exn.capture(body)) } |
35 fork(name, daemon) { result.fulfill_result(Exn.capture(body)) } |
38 result |
36 result |
39 } |
37 } |
40 |
|
41 def future[A](body: => A): Future[A] = future()(body) |
|
42 |
38 |
43 |
39 |
44 /* thread as actor */ |
40 /* thread as actor */ |
45 |
41 |
46 def actor(name: String, daemon: Boolean = false)(body: => Unit): (Thread, Actor) = |
42 def actor(name: String, daemon: Boolean = false)(body: => Unit): (Thread, Actor) = |