Current section
Files
Jump to
Current section
Files
media/rustler_elixir_fun_sequence_diagram.svg
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1676" height="1022"><desc>title%20RustlerElixirFun%3A%20How%20Elixir%20code%20is%20called%20from%20Native%20code%0A%0Aparticipantgroup%20Rust%0Aparticipant%20%22Your%20Native%20Code%5Cn%20--(executing%20on%20the%20Dirty%20CPU%20Scheduler%5Cn%20or%20on%20a%20non-OTP%20thread)--%22%20as%20Your%20Native%20Code%0Aparticipant%20%22rustler_elixir_fun%3A%3Aapply_elixir_fun%5Cn%20**Rust**%22%20as%20apply_elixir_function%0Aparticipant%20%3A0.1%20%22rustler_elixir_fun%3A%3Afill_future%20%5Cn%20**Rust**%20NIF%20(on%20normal%20Scheduler)%22%20as%20fill_future%0Aend%0A%0Aparticipantgroup%20Elixir%0Aparticipant%20FunExecutionServer%0Aend%0A%0Aactivate%20Your%20Native%20Code%0AYour%20Native%20Code-%3E*apply_elixir_function%3Aapply_elixir_function(pid_or_name%2C%20function%2C%20parameters)%0Aactivate%20apply_elixir_function%0Abox%20over%20apply_elixir_function%3ACreate%20future%0Abox%20over%20apply_elixir_function%3ALook%20up%20PID%20for%20registered%20process%20name%0Aapply_elixir_function-%3E(4)FunExecutionServer%3Asend(pid%2C%20%7Bfunction%2C%20parameters%2C%20future_ref%7D)%0Aactivate%20FunExecutionServer%0Abox%20over%20apply_elixir_function%3AWait%20on%20future%0Adeactivate%20apply_elixir_function%0Abox%20over%20FunExecutionServer%3Aresult%20%3D%20apply(fun%2C%20parameters)%0AFunExecutionServer-%3E*fill_future%3Afill_future(future_ref%2C%20result)%0Aactivate%20fill_future%0Afill_future--%23999999%3E%3Eapply_elixir_function%3A%20Fills%20future%0Aactivate%20apply_elixir_function%0Abox%20over%20apply_elixir_function%3AExtract%20result%20from%20future%0Afill_future-%3EFunExecutionServer%3A%3Aok%0Adeactivate%20fill_future%0Adestroysilent%20fill_future%0Adeactivate%20FunExecutionServer%0Aapply_elixir_function-%3EYour%20Native%20Code%3Aresult%0Adeactivate%20apply_elixir_function%0Adestroysilent%20apply_elixir_function</desc><defs/><g><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g><rect fill="white" stroke="none" x="0" y="0" width="1676" height="1022"/></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="16.5pt" font-style="normal" font-weight="normal" text-decoration="normal" x="537.1286627239255" y="26.3876361" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">RustlerElixirFun: How Elixir code is called from Native code</text></g><g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 8.795878699999992 54.270571579000006 L 1153.6511305092192 54.270571579000006 L 1153.6511305092192 1013.5101538826129 L 8.795878699999992 1013.5101538826129 L 8.795878699999992 54.270571579000006" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="565.9568381922561" y="78.899031939" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Rust</text></g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 1422.7749347442025 84.704311881 L 1615.4908026504447 84.704311881 L 1615.4908026504447 1013.5101538826129 L 1422.7749347442025 1013.5101538826129 L 1422.7749347442025 84.704311881" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="1502.4662026664398" y="109.33277224099999" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Elixir</text></g></g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 143.32881618171606 174.15839825999996 L 143.32881618171606 1013.5101538826129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray="13.532121076923076,5.863919133333333"/><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 733.9106597579491 277.246096624 L 733.9106597579491 951.9390029826129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray="13.532121076923076,5.863919133333333"/><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 1015.3015292854377 737.3195627026129 L 1015.3015292854377 902.6820822626129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray="13.532121076923076,5.863919133333333"/><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 1519.1328686973236 174.15839825999996 L 1519.1328686973236 1013.5101538826129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray="13.532121076923076,5.863919133333333"/></g><g><path fill="none" stroke="none"/><g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 17.59175739999999 96.226912978 L 269.0658749634321 96.226912978 L 269.0658749634321 174.15839825999998 L 17.59175739999999 174.15839825999998 L 17.59175739999999 96.226912978 Z" stroke-miterlimit="10" stroke-width="2.814681184" stroke-dasharray=""/></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="83.91214824348364" y="125.95698298399998" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Your Native Code</text><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="36.678814179" y="143.54874038399998" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve"> </text><text fill="black" stroke="none" font-family="sans-serif" font-size="8.8pt" font-style="normal" font-weight="normal" text-decoration="normal" x="40.49548078208838" y="143.54874038399998" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">(executing on the Dirty CPU Scheduler</text><text fill="black" stroke="none" font-family="sans-serif" font-size="8.8pt" font-style="normal" font-weight="normal" text-decoration="normal" x="75.33714748054419" y="157.62214630399998" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve"> or on a non-OTP thread)</text></g><path fill="none" stroke="none"/><g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 1431.5708134442025 126.66065327999999 L 1606.6949239504447 126.66065327999999 L 1606.6949239504447 174.15839825999998 L 1431.5708134442025 174.15839825999998 L 1431.5708134442025 126.66065327999999 Z" stroke-miterlimit="10" stroke-width="2.814681184" stroke-dasharray=""/></g><g><g/><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="1450.6578702232025" y="156.56664085999998" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">FunExecutionServer</text></g></g><g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 134.53293748171606 182.95427696000002 L 152.12469488171607 182.95427696000002 L 152.12469488171607 995.9183964826129 L 134.53293748171606 995.9183964826129 L 134.53293748171606 182.95427696000002" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 725.1147810579491 277.246096624 L 742.7065384579491 277.246096624 L 742.7065384579491 576.1790649186129 L 725.1147810579491 576.1790649186129 L 725.1147810579491 277.246096624" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 1510.3369899973236 509.3303867986129 L 1527.9287473973236 509.3303867986129 L 1527.9287473973236 902.6820822626129 L 1510.3369899973236 902.6820822626129 L 1510.3369899973236 509.3303867986129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 1006.5056505854377 737.3195627026129 L 1024.0974079854377 737.3195627026129 L 1024.0974079854377 902.6820822626129 L 1006.5056505854377 902.6820822626129 L 1006.5056505854377 737.3195627026129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 725.1147810579491 786.5764834226129 L 742.7065384579491 786.5764834226129 L 742.7065384579491 951.9390029826129 L 725.1147810579491 951.9390029826129 L 725.1147810579491 786.5764834226129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><path fill="none" stroke="none"/><g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 599.6652701542421 210.83721243900007 L 868.1560493616562 210.83721243900007 L 868.1560493616562 275.75079724500006 L 599.6652701542421 275.75079724500006 L 599.6652701542421 210.83721243900007 Z" stroke-miterlimit="10" stroke-width="2.814681184" stroke-dasharray=""/></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="618.7523269332421" y="240.56728244500005" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">rustler_elixir_fun::apply_elixir_fun</text><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="715.5106596625817" y="258.15903984500005" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve"> </text><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="bold" text-decoration="normal" x="719.3273262656701" y="258.15903984500005" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Rust</text></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="179.9783107650494" y="236.25730188200004" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">apply_elixir_function(pid_or_name, function, parameters)</text></g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 152.12469488171607 243.29400484200002 L 585.1813898949088 243.29400484200002" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g transform="translate(599.6652701542421,243.29400484200002) translate(-599.6652701542421,-243.29400484200002)"><path fill="black" stroke="none" paint-order="stroke fill markers" d=" M 585.0054723209088 235.96410592533334 L 599.6652701542421 243.29400484200002 L 585.0054723209088 250.6239037586667 Z"/></g></g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 663.5655322226562 303.633732724 L 804.2557872932422 303.633732724 L 804.2557872932422 344.094774744 L 663.5655322226562 344.094774744 L 663.5655322226562 303.633732724" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="688.1939925826562" y="328.262193084" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Create future</text></g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 568.457202449707 370.482410844 L 899.3641170661913 370.482410844 L 899.3641170661913 410.943452864 L 568.457202449707 410.943452864 L 568.457202449707 370.482410844" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="593.085662809707" y="395.110871204" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Look up PID for registered process name</text></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="974.3801016299801" y="453.16367062399996" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">send(pid, {function, parameters, future_ref})</text></g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 742.7065384579491 438.9633571986129 L 1495.913582865925 508.00822414272466" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g transform="translate(1510.3369899973236,509.3303867986129) rotate(5.237543043739115,0,0) translate(-1510.3369899973236,-509.3303867986129)"><path fill="black" stroke="none" paint-order="stroke fill markers" d=" M 1495.6771921639902 502.00048788194624 L 1510.3369899973236 509.3303867986129 L 1495.6771921639902 516.6602857152795 Z"/><g transform="rotate(-5.237543043739115,0,0)"/></g></g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 659.8988642844238 535.7180228986128 L 807.9224552314746 535.7180228986128 L 807.9224552314746 576.1790649186129 L 659.8988642844238 576.1790649186129 L 659.8988642844238 535.7180228986128" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="684.5273246444237" y="560.3464832586129" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Wait on future</text></g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 1388.2960724608588 602.5667010186129 L 1649.9696649337884 602.5667010186129 L 1649.9696649337884 643.0277430386129 L 1388.2960724608588 643.0277430386129 L 1388.2960724608588 602.5667010186129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="1412.9245328208588" y="627.195161378613" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">result = apply(fun, parameters)</text></g><path fill="none" stroke="none"/><g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 885.7478067616562 670.910678517613 L 1144.8552518092192 670.910678517613 L 1144.8552518092192 735.824263323613 L 885.7478067616562 735.824263323613 L 885.7478067616562 670.910678517613 Z" stroke-miterlimit="10" stroke-width="0.2814681184" stroke-dasharray=""/></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="919.1181949348518" y="700.6407485236128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">rustler_elixir_fun::fill_future </text><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="904.8348635406562" y="718.2325059236128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve"> </text><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="bold" text-decoration="normal" x="908.6515301437446" y="718.2325059236128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Rust</text><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="941.6348637313911" y="718.2325059236128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve"> NIF (on normal Scheduler)</text></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="1233.0877896044433" y="696.3307679606128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">fill_future(future_ref, result)</text></g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 1510.3369899973236 703.3674709206128 L 1159.3391320685525 703.3674709206128" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g transform="translate(1144.8552518092192,703.3674709206128) translate(-1144.8552518092192,-703.3674709206128)"><path fill="black" stroke="none" paint-order="stroke fill markers" d=" M 1159.5150496425526 696.0375720039461 L 1144.8552518092192 703.3674709206128 L 1159.5150496425526 710.6973698372796 Z"/></g></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="838.439426583461" y="779.5397804626128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Fills future</text></g><g><path fill="none" stroke="#999999" paint-order="fill stroke markers" d=" M 1006.5056505854377 786.5764834226129 L 744.9055081329491 786.5764834226129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray="7.0367029599999995"/><g transform="translate(742.7065384579491,786.5764834226129) translate(-742.7065384579491,-786.5764834226129)"><path fill="none" stroke="#999999" paint-order="fill stroke markers" d=" M 757.7783401012381 779.8528245919415 L 744.3545536977716 786.5764834226129 L 757.7783401012381 793.3001422532843" stroke-miterlimit="10" stroke-width="1.4659797833333332"/></g></g><path fill="white" stroke="black" paint-order="fill stroke markers" d=" M 622.1988635214843 812.9641195226128 L 845.622455994414 812.9641195226128 L 845.622455994414 853.4251615426128 L 622.1988635214843 853.4251615426128 L 622.1988635214843 812.9641195226128" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="646.8273238814843" y="837.5925798826129" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">Extract result from future</text></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="1256.8921991821155" y="895.6453793026128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">:ok</text></g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 1024.0974079854377 902.6820822626129 L 1495.8531097379903 902.6820822626129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g transform="translate(1510.3369899973236,902.6820822626129) translate(-1510.3369899973236,-902.6820822626129)"><path fill="black" stroke="none" paint-order="stroke fill markers" d=" M 1495.6771921639902 895.3521833459462 L 1510.3369899973236 902.6820822626129 L 1495.6771921639902 910.0119811792796 Z"/></g></g><g><text fill="black" stroke="none" font-family="sans-serif" font-size="11pt" font-style="normal" font-weight="normal" text-decoration="normal" x="419.01140438218613" y="944.9023000226128" text-anchor="start" dominant-baseline="alphabetic" xml:space="preserve">result</text></g><g><path fill="none" stroke="black" paint-order="fill stroke markers" d=" M 725.1147810579491 951.9390029826129 L 166.6085751410494 951.9390029826129" stroke-miterlimit="10" stroke-width="1.4659797833333332" stroke-dasharray=""/><g transform="translate(152.12469488171607,951.9390029826129) translate(-152.12469488171607,-951.9390029826129)"><path fill="black" stroke="none" paint-order="stroke fill markers" d=" M 166.7844927150494 944.6091040659462 L 152.12469488171607 951.9390029826129 L 166.7844927150494 959.2689018992796 Z"/></g></g></g><g/></g></svg>