-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RD-9460 implement function package in truffle for invoke after (#117)
- Added Function.InvokeAfter entry
- Loading branch information
1 parent
f097d9b
commit 942b10d
Showing
3 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
37 changes: 37 additions & 0 deletions
37
...raw/runtime/truffle/ast/expressions/builtin/function_package/FunctionInvokeAfterNode.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2023 RAW Labs S.A. | ||
* | ||
* Use of this software is governed by the Business Source License | ||
* included in the file licenses/BSL.txt. | ||
* | ||
* As of the Change Date specified in that file, in accordance with | ||
* the Business Source License, use of this software will be governed | ||
* by the Apache License, Version 2.0, included in the file | ||
* licenses/APL.txt. | ||
*/ | ||
|
||
package raw.runtime.truffle.ast.expressions.builtin.function_package; | ||
|
||
import com.oracle.truffle.api.dsl.NodeChild; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.nodes.NodeInfo; | ||
import raw.runtime.truffle.ExpressionNode; | ||
import raw.runtime.truffle.runtime.exceptions.RawTruffleInternalErrorException; | ||
import raw.runtime.truffle.runtime.function.Closure; | ||
|
||
@NodeInfo(shortName = "Function.InvokeAfter") | ||
@NodeChild(value = "function") | ||
@NodeChild(value = "sleepTime") | ||
public abstract class FunctionInvokeAfterNode extends ExpressionNode { | ||
|
||
@Specialization | ||
protected Object invokeAfter(Closure function, long sleepTime) { | ||
try { | ||
Thread.sleep(sleepTime); | ||
return function.call(); | ||
} catch (InterruptedException e) { | ||
throw new RawTruffleInternalErrorException(e); | ||
} | ||
} | ||
|
||
} |