|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | /*** |
7 | | -* Core Lunatik module. |
8 | | -* Provides functionalities to create and manage Lunatik runtimes, |
9 | | -* which are isolated Lua environments running within the Linux kernel. |
10 | | -* This module exposes the `lunatik` global table in Lua, which can be |
11 | | -* used to create new runtimes. Runtime objects themselves have methods |
12 | | -* to control their execution (e.g., `resume`, `stop`). |
13 | | -* |
14 | | -* If a global Lunatik environment (`lunatik_env`) is configured at the C level, |
15 | | -* it can be exposed to Lua scripts as `lunatik._ENV`. This allows for a shared |
16 | | -* environment across multiple scripts or runtimes. |
17 | | -* |
| 7 | +* Manages Lunatik runtimes — isolated Lua states running in the kernel. |
18 | 8 | * @module lunatik |
19 | 9 | */ |
20 | 10 |
|
|
30 | 20 | #include "lunatik_sym.h" |
31 | 21 |
|
32 | 22 | /*** |
33 | | -* Shared environment |
34 | | -* @field _ENV points to a shared global Lunatik runtime object. Scripts can |
35 | | -* share RCU tables or other Lunatik objects through this mechanism. |
| 23 | +* Shared global environment; scripts exchange objects (e.g. RCU tables) through it. |
| 24 | +* @field _ENV |
36 | 25 | * @within lunatik |
37 | 26 | */ |
38 | 27 |
|
@@ -143,18 +132,11 @@ static inline int lunatik_resume(lua_State *Lto, lua_State *Lfrom, int nargs) |
143 | 132 | } |
144 | 133 |
|
145 | 134 | /*** |
146 | | -* Resumes a Lunatik runtime that has yielded. |
147 | | -* This function is used to continue the execution of a Lua script within a |
148 | | -* Lunatik runtime from the point where it last yielded. It's analogous to |
149 | | -* Lua's `coroutine.resume`. |
150 | | -* The `resume` method is called on a Lunatik runtime object. |
| 135 | +* Resumes a yielded runtime, analogous to `coroutine.resume`. |
151 | 136 | * @function resume |
152 | | -* @param ... Arguments to pass to the Lua script upon resumption. These arguments will be received by the `coroutine.yield()` call that suspended the script. |
153 | | -* @treturn vararg Values returned by the `coroutine.yield()` call if the script yielded again, or values returned by the script if it completed. |
154 | | -* @raise Error if the runtime cannot be resumed or if an error occurs within the resumed script. The error message will be propagated from the Lua C API error. |
155 | | -* @usage |
156 | | -* -- Assuming 'rt' is a Lunatik runtime object that has yielded. |
157 | | -* local success, res_or_err = pcall(function() return rt:resume("arg_to_script") end) |
| 137 | +* @param ... values delivered to the script as return values of `coroutine.yield()` |
| 138 | +* @treturn vararg values passed to the next `coroutine.yield()`, or returned by the script |
| 139 | +* @raise if the runtime errors on resumption |
158 | 140 | */ |
159 | 141 | static int lunatik_lresume(lua_State *L) |
160 | 142 | { |
@@ -185,18 +167,8 @@ static const luaL_Reg lunatik_stub_lib[] = { |
185 | 167 | }; |
186 | 168 |
|
187 | 169 | /*** |
188 | | -* Stops and releases a Lunatik runtime environment. |
189 | | -* This method is called on a Lunatik runtime object. Once stopped, the runtime |
190 | | -* cannot be resumed or used further. It ensures that the associated Lua state |
191 | | -* is closed and all kernel resources are freed. |
192 | | -* |
193 | | -* This method provides an explicit way to release the runtime. |
| 170 | +* Stops the runtime and releases all associated kernel resources. |
194 | 171 | * @function stop |
195 | | -* @treturn nil Does not return any value to Lua. |
196 | | -* @raise Error May raise an error if the underlying C function encounters a critical issue during cleanup and calls `lua_error`. |
197 | | -* @usage |
198 | | -* -- Assuming 'rt' is a Lunatik runtime object: |
199 | | -* rt:stop() |
200 | 172 | */ |
201 | 173 | static const luaL_Reg lunatik_mt[] = { |
202 | 174 | {"__gc", lunatik_deleteobject}, |
@@ -330,7 +302,7 @@ LUNATIK_NEWLIB(lunatik_stub, lunatik_stub_lib, NULL, NULL); |
330 | 302 |
|
331 | 303 | static int __init lunatik_init(void) |
332 | 304 | { |
333 | | - return 0; |
| 305 | + return 0; |
334 | 306 | } |
335 | 307 |
|
336 | 308 | static void __exit lunatik_exit(void) |
|
0 commit comments