Added futures to kraken!!!
Added a templated future class that wraps the pthread library to allow multithreaded development.
This commit is contained in:
29
tests/test_future.krak
Normal file
29
tests/test_future.krak
Normal file
@@ -0,0 +1,29 @@
|
||||
import future:*
|
||||
import io:*
|
||||
|
||||
|
||||
fun main() : int {
|
||||
var a = 0
|
||||
var c = fun() : int {
|
||||
var b = a
|
||||
print("Thread ")
|
||||
print(b)
|
||||
println(" Started!")
|
||||
var x : int = 0
|
||||
for(var i = 1; i < 100; i++;) {
|
||||
x++
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
var gadget1.construct(c) : future<int>
|
||||
gadget1.run()
|
||||
gadget1.finish()
|
||||
|
||||
println("Threads have finished")
|
||||
|
||||
pthread_exit()
|
||||
println("All Done!")
|
||||
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user