Last active
August 29, 2015 14:23
-
-
Save albertnetymk/88f3be200b13a041bc5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Client { | |
server : Server | |
def init(s:Server) : void { | |
this.server = s | |
} | |
def block() : void { | |
get this.server.f(); | |
} | |
def nonblock() : void { | |
print "nonblock" | |
} | |
def dummy() : void { | |
(); | |
} | |
} | |
class Server { | |
def init() : void { | |
(); | |
} | |
def bubbleSort(arr:[int], head:int, tail:int) : void { | |
let | |
swapped = true | |
tmp = 0 | |
in { | |
while (swapped) { | |
swapped = false; | |
while (head < tail - 1) { | |
if (arr[head] > arr[head+1]) then { | |
tmp = arr[head]; | |
arr[head] = arr[head+1]; | |
arr[head+1] = tmp; | |
swapped = true; | |
}; | |
head = head + 1; | |
}; | |
} | |
} | |
} | |
def heavy() : void { | |
print "heavy"; | |
let | |
length = 100*1000*1000 | |
arr = new [int](length) | |
in { | |
repeat i <- length { | |
arr[i] = i+1 | |
}; | |
this.bubbleSort(arr, 0, length) | |
} | |
} | |
def f() : void { | |
this.heavy(); | |
} | |
} | |
class Main { | |
def main() : void { | |
let | |
s = new Server() | |
c1 = new Client(s) | |
c2 = new Client(s) | |
in { | |
c1.block(); | |
c2.dummy(); | |
c2.nonblock(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment