diff options
author | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2018-11-04 14:05:24 +0100 |
---|---|---|
committer | Benoit Germain <b n t DOT g e r m a i n AT g m a i l DOT c o m> | 2018-11-04 14:05:24 +0100 |
commit | e4596baf5284636e550eade3cb6f57bde7644fe1 (patch) | |
tree | e61ef95c60ac5f933d1b268449354e70238c9935 | |
parent | c61bceb0281c61d1ba7f486a381519c26bb700dc (diff) | |
download | lanes-e4596baf5284636e550eade3cb6f57bde7644fe1.tar.gz lanes-e4596baf5284636e550eade3cb6f57bde7644fe1.tar.bz2 lanes-e4596baf5284636e550eade3cb6f57bde7644fe1.zip |
Documentation for __lanesclone
-rw-r--r-- | index.html | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -70,7 +70,7 @@ | |||
70 | </p> | 70 | </p> |
71 | 71 | ||
72 | <p> | 72 | <p> |
73 | This document was revised on 2-Nov-18, and applies to version <tt>3.13</tt>. | 73 | This document was revised on 4-Nov-18, and applies to version <tt>3.13</tt>. |
74 | </p> | 74 | </p> |
75 | </font> | 75 | </font> |
76 | </center> | 76 | </center> |
@@ -113,7 +113,7 @@ | |||
113 | 113 | ||
114 | <ul> | 114 | <ul> |
115 | <li>Coroutines are not passed between states.</li> | 115 | <li>Coroutines are not passed between states.</li> |
116 | <li>Sharing full userdata between states needs special C side preparations (-> <A HREF="#deep_userdata">deep userdata</A>).</li> | 116 | <li>Sharing full userdata between states needs special C side preparations (-> <A HREF="#deep_userdata">deep userdata</A> and -> <A HREF="#clonable_userdata">clonable userdata</A>).</li> |
117 | <li>Network level parallelism not included.</li> | 117 | <li>Network level parallelism not included.</li> |
118 | <li>Multi-CPU is done with OS threads, not processes. A lane is a Lua full userdata, therefore it will exist only as long as the Lua state that created it still exists. Therefore, a lane won't continue execution after the main program's termination.</li> | 118 | <li>Multi-CPU is done with OS threads, not processes. A lane is a Lua full userdata, therefore it will exist only as long as the Lua state that created it still exists. Therefore, a lane won't continue execution after the main program's termination.</li> |
119 | <li>Just like independant Lua states, Lanes universes cannot communicate together.</li> | 119 | <li>Just like independant Lua states, Lanes universes cannot communicate together.</li> |
@@ -1510,6 +1510,21 @@ events to a common Linda, but... :).</font> | |||
1510 | } | 1510 | } |
1511 | </pre></td></tr></table> | 1511 | </pre></td></tr></table> |
1512 | 1512 | ||
1513 | <h3 id="clonable_userdata">Clonable full userdata in your own apps</h3> | ||
1514 | <p> | ||
1515 | Starting with version 3.13, a new way of passing full userdata across lanes uses a new <tt>__lanesclone</tt> metamethod. A typical implementation would look like: | ||
1516 | <table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre> | ||
1517 | static int clonable_lanesclone( lua_State* L) | ||
1518 | { | ||
1519 | // no need to set the metatable, the Lane copying mechanism will take care of it | ||
1520 | struct s_MyClonableUserdata* self = lua_touserdata( L, 1); | ||
1521 | struct s_MyClonableUserdata* to = lua_newuserdata( L, sizeof( struct s_MyClonableUserdata)); | ||
1522 | memcpy( to, self, sizeof(struct s_MyClonableUserdata)); | ||
1523 | return 1; | ||
1524 | } | ||
1525 | </pre></td></tr></table> | ||
1526 | </p> | ||
1527 | Of course, more complex objects may require smarter cloning behavior than a simple <tt>memcpy</tt>. | ||
1513 | 1528 | ||
1514 | <h3 id="deep_userdata">Deep userdata in your own apps</h3> | 1529 | <h3 id="deep_userdata">Deep userdata in your own apps</h3> |
1515 | 1530 | ||