Skip to content

Commit 9a314bf

Browse files
committed
Add lambda demonstration to Jai example
1 parent d2ea0f3 commit 9a314bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/counter.jai

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ coroutine_wake_up :: (id: int) #foreign coroutine;
77
coroutine_init :: () #foreign coroutine;
88
coroutine_finish :: () #foreign coroutine;
99
coroutine_yield :: () #foreign coroutine;
10-
coroutine_go :: (f: (*void) #c_call, arg: *void) #foreign coroutine;
10+
coroutine_go :: (f: (*void) #c_call, arg: *void = null) #foreign coroutine;
1111
coroutine_id :: () -> int #foreign coroutine;
1212
coroutine_alive :: () -> int #foreign coroutine;
1313

@@ -24,6 +24,11 @@ counter :: (arg: *void) #c_call {
2424
main :: () {
2525
coroutine_init();
2626
defer coroutine_finish();
27+
coroutine_go((arg: *void) #c_call {
28+
push_context {
29+
print("[%] Hello from Jai Lambda\n", coroutine_id());
30+
}
31+
});
2732
coroutine_go(counter, cast(*void) 5);
2833
coroutine_go(counter, cast(*void) 10);
2934
while coroutine_alive() > 1 {

0 commit comments

Comments
 (0)