Skip to content

Commit

Permalink
[enhance] stdlib,scheduler.opa: +{point,yield,switch}
Browse files Browse the repository at this point in the history
  • Loading branch information
OpaOnWindowsNow committed May 2, 2012
1 parent d9e3bda commit b403592
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion stdlib/core/rpc/core/scheduler.opa
@@ -1,5 +1,5 @@
/*
Copyright © 2011 MLstate
Copyright © 2011, 2012 MLstate
This file is part of OPA.
Expand Down Expand Up @@ -168,6 +168,34 @@ Scheduler =
*/
push = @may_cps(%%BslScheduler.push%%)

/**
* Introduce a scheduling point.
*
* Warning: this function is server-only.
*/
@server_private
point() = @callcc(Continuation.return(_,void))

/**
* Reschedule the current computation for later.
*
* Warning: this function is server-only.
*/
@server_private
yield() = @callcc(k -> Scheduler_push( -> Continuation.return(k,void)))

/**
* Switch to the task provided by the function while rescheduling the current computation
*
* Warning: this function is server-only.
*/
@server_private
switch(f) = @callcc(k ->
do Scheduler_push( -> Continuation.return(k,void))
f()
)


/**
* {1 GC}
*/
Expand Down

0 comments on commit b403592

Please sign in to comment.