create-mendix-widget-gleam 2.0.13 → 2.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/README.md +3 -2
  2. package/package.json +5 -1
  3. package/src/index.mjs +22 -7
  4. package/src/templates/readme_md.mjs +6 -6
  5. package/template/docs/glendix_guide.md +204 -1
  6. package/template/gleam.toml +1 -1
  7. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@command.cache +0 -0
  8. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@command.cache_inline +0 -0
  9. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@command.cache_meta +0 -0
  10. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache +0 -0
  11. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache_inline +0 -0
  12. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache_meta +0 -0
  13. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@event.cache +0 -0
  14. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@event.cache_inline +0 -0
  15. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@event.cache_meta +0 -0
  16. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@internal@consts.cache +0 -0
  17. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@internal@consts.cache_inline +0 -0
  18. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@internal@consts.cache_meta +0 -0
  19. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@stdout.cache +0 -0
  20. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@stdout.cache_inline +0 -0
  21. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@stdout.cache_meta +0 -0
  22. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@style.cache +0 -0
  23. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@style.cache_inline +0 -0
  24. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@style.cache_meta +0 -0
  25. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@terminal.cache +0 -0
  26. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@terminal.cache_inline +0 -0
  27. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@terminal.cache_meta +0 -0
  28. package/tui/build/dev/javascript/etch/etch/command.mjs +479 -0
  29. package/tui/build/dev/javascript/etch/etch/cursor.mjs +164 -0
  30. package/tui/build/dev/javascript/etch/etch/event.mjs +2399 -0
  31. package/tui/build/dev/javascript/etch/etch/internal/consts.mjs +3 -0
  32. package/tui/build/dev/javascript/etch/etch/stdout.mjs +375 -0
  33. package/tui/build/dev/javascript/etch/etch/style.mjs +741 -0
  34. package/tui/build/dev/javascript/etch/etch/terminal.mjs +137 -0
  35. package/tui/build/dev/javascript/etch/gleam.mjs +1 -0
  36. package/tui/build/dev/javascript/etch/input/event_ffi.erl +73 -0
  37. package/tui/build/dev/javascript/etch/input/input_ffi.mjs +192 -0
  38. package/tui/build/dev/javascript/etch/input/signal_handler.erl +33 -0
  39. package/tui/build/dev/javascript/etch/terminal/terminal_ffi.erl +22 -0
  40. package/tui/build/dev/javascript/etch/terminal/terminal_ffi.mjs +37 -0
  41. package/tui/build/dev/javascript/etch/terminal/tty_state.erl +29 -0
  42. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@application.cache +0 -0
  43. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@application.cache_inline +0 -0
  44. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@application.cache_meta +0 -0
  45. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@atom.cache +0 -0
  46. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@atom.cache_inline +0 -0
  47. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@atom.cache_meta +0 -0
  48. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@charlist.cache +0 -0
  49. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@charlist.cache_inline +0 -0
  50. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@charlist.cache_meta +0 -0
  51. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@node.cache +0 -0
  52. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@node.cache_inline +0 -0
  53. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@node.cache_meta +0 -0
  54. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@port.cache +0 -0
  55. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@port.cache_inline +0 -0
  56. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@port.cache_meta +0 -0
  57. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@process.cache +0 -0
  58. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@process.cache_inline +0 -0
  59. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@process.cache_meta +0 -0
  60. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@reference.cache +0 -0
  61. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@reference.cache_inline +0 -0
  62. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@reference.cache_meta +0 -0
  63. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/application.mjs +38 -0
  64. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/atom.mjs +2 -0
  65. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/charlist.mjs +1 -0
  66. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/node.mjs +12 -0
  67. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/port.mjs +1 -0
  68. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/process.mjs +161 -0
  69. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/reference.mjs +1 -0
  70. package/tui/build/dev/javascript/gleam_erlang/gleam.mjs +1 -0
  71. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@application.erl +43 -0
  72. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@atom.erl +94 -0
  73. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@charlist.erl +42 -0
  74. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@node.erl +80 -0
  75. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@port.erl +8 -0
  76. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@process.erl +868 -0
  77. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@reference.erl +21 -0
  78. package/tui/build/dev/javascript/gleam_erlang/gleam_erlang_ffi.erl +164 -0
  79. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@array.cache +0 -0
  80. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@array.cache_inline +0 -0
  81. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@array.cache_meta +0 -0
  82. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@promise.cache +0 -0
  83. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@promise.cache_inline +0 -0
  84. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@promise.cache_meta +0 -0
  85. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@symbol.cache +0 -0
  86. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@symbol.cache_inline +0 -0
  87. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@symbol.cache_meta +0 -0
  88. package/tui/build/dev/javascript/gleam_javascript/gleam/javascript/array.mjs +24 -0
  89. package/tui/build/dev/javascript/gleam_javascript/gleam/javascript/promise.mjs +105 -0
  90. package/tui/build/dev/javascript/gleam_javascript/gleam/javascript/symbol.mjs +7 -0
  91. package/tui/build/dev/javascript/gleam_javascript/gleam.mjs +1 -0
  92. package/tui/build/dev/javascript/gleam_javascript/gleam_javascript_ffi.mjs +133 -0
  93. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache +0 -0
  94. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache_inline +0 -0
  95. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache_meta +0 -0
  96. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache +0 -0
  97. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache_inline +0 -0
  98. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache_meta +0 -0
  99. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache +0 -0
  100. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache_inline +0 -0
  101. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache_meta +0 -0
  102. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache +0 -0
  103. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache_inline +0 -0
  104. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache_meta +0 -0
  105. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache +0 -0
  106. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache_inline +0 -0
  107. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache_meta +0 -0
  108. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache +0 -0
  109. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache_inline +0 -0
  110. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache_meta +0 -0
  111. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache +0 -0
  112. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache_inline +0 -0
  113. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache_meta +0 -0
  114. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache +0 -0
  115. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache_inline +0 -0
  116. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache_meta +0 -0
  117. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache +0 -0
  118. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache_inline +0 -0
  119. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache_meta +0 -0
  120. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache +0 -0
  121. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache_inline +0 -0
  122. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache_meta +0 -0
  123. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache +0 -0
  124. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache_inline +0 -0
  125. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache_meta +0 -0
  126. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache +0 -0
  127. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache_inline +0 -0
  128. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache_meta +0 -0
  129. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache +0 -0
  130. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache_inline +0 -0
  131. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache_meta +0 -0
  132. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache +0 -0
  133. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache_inline +0 -0
  134. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache_meta +0 -0
  135. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache +0 -0
  136. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache_inline +0 -0
  137. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache_meta +0 -0
  138. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache +0 -0
  139. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache_inline +0 -0
  140. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache_meta +0 -0
  141. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache +0 -0
  142. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache_inline +0 -0
  143. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache_meta +0 -0
  144. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache +0 -0
  145. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache_inline +0 -0
  146. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache_meta +0 -0
  147. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache +0 -0
  148. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache_inline +0 -0
  149. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache_meta +0 -0
  150. package/tui/build/dev/javascript/gleam_stdlib/dict.mjs +710 -0
  151. package/tui/build/dev/javascript/gleam_stdlib/gleam/bit_array.mjs +286 -0
  152. package/tui/build/dev/javascript/gleam_stdlib/gleam/bool.mjs +295 -0
  153. package/tui/build/dev/javascript/gleam_stdlib/gleam/bytes_tree.mjs +225 -0
  154. package/tui/build/dev/javascript/gleam_stdlib/gleam/dict.mjs +455 -0
  155. package/tui/build/dev/javascript/gleam_stdlib/gleam/dynamic/decode.mjs +993 -0
  156. package/tui/build/dev/javascript/gleam_stdlib/gleam/dynamic.mjs +35 -0
  157. package/tui/build/dev/javascript/gleam_stdlib/gleam/float.mjs +528 -0
  158. package/tui/build/dev/javascript/gleam_stdlib/gleam/function.mjs +6 -0
  159. package/tui/build/dev/javascript/gleam_stdlib/gleam/int.mjs +764 -0
  160. package/tui/build/dev/javascript/gleam_stdlib/gleam/io.mjs +8 -0
  161. package/tui/build/dev/javascript/gleam_stdlib/gleam/list.mjs +3063 -0
  162. package/tui/build/dev/javascript/gleam_stdlib/gleam/option.mjs +386 -0
  163. package/tui/build/dev/javascript/gleam_stdlib/gleam/order.mjs +166 -0
  164. package/tui/build/dev/javascript/gleam_stdlib/gleam/pair.mjs +96 -0
  165. package/tui/build/dev/javascript/gleam_stdlib/gleam/result.mjs +448 -0
  166. package/tui/build/dev/javascript/gleam_stdlib/gleam/set.mjs +413 -0
  167. package/tui/build/dev/javascript/gleam_stdlib/gleam/string.mjs +695 -0
  168. package/tui/build/dev/javascript/gleam_stdlib/gleam/string_tree.mjs +128 -0
  169. package/tui/build/dev/javascript/gleam_stdlib/gleam/uri.mjs +1151 -0
  170. package/tui/build/dev/javascript/gleam_stdlib/gleam.mjs +1 -0
  171. package/tui/build/dev/javascript/gleam_stdlib/gleam@bit_array.erl +347 -0
  172. package/tui/build/dev/javascript/gleam_stdlib/gleam@bool.erl +334 -0
  173. package/tui/build/dev/javascript/gleam_stdlib/gleam@bytes_tree.erl +211 -0
  174. package/tui/build/dev/javascript/gleam_stdlib/gleam@dict.erl +513 -0
  175. package/tui/build/dev/javascript/gleam_stdlib/gleam@dynamic.erl +105 -0
  176. package/tui/build/dev/javascript/gleam_stdlib/gleam@dynamic@decode.erl +1114 -0
  177. package/tui/build/dev/javascript/gleam_stdlib/gleam@float.erl +711 -0
  178. package/tui/build/dev/javascript/gleam_stdlib/gleam@function.erl +18 -0
  179. package/tui/build/dev/javascript/gleam_stdlib/gleam@int.erl +972 -0
  180. package/tui/build/dev/javascript/gleam_stdlib/gleam@io.erl +76 -0
  181. package/tui/build/dev/javascript/gleam_stdlib/gleam@list.erl +2735 -0
  182. package/tui/build/dev/javascript/gleam_stdlib/gleam@option.erl +381 -0
  183. package/tui/build/dev/javascript/gleam_stdlib/gleam@order.erl +188 -0
  184. package/tui/build/dev/javascript/gleam_stdlib/gleam@pair.erl +104 -0
  185. package/tui/build/dev/javascript/gleam_stdlib/gleam@result.erl +500 -0
  186. package/tui/build/dev/javascript/gleam_stdlib/gleam@set.erl +430 -0
  187. package/tui/build/dev/javascript/gleam_stdlib/gleam@string.erl +964 -0
  188. package/tui/build/dev/javascript/gleam_stdlib/gleam@string_tree.erl +202 -0
  189. package/tui/build/dev/javascript/gleam_stdlib/gleam@uri.erl +1042 -0
  190. package/tui/build/dev/javascript/gleam_stdlib/gleam_stdlib.erl +534 -0
  191. package/tui/build/dev/javascript/gleam_stdlib/gleam_stdlib.mjs +1133 -0
  192. package/tui/build/dev/javascript/gleam_version +1 -0
  193. package/tui/build/dev/javascript/prelude.mjs +1575 -0
  194. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache +0 -0
  195. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache_inline +0 -0
  196. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache_meta +0 -0
  197. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache_warnings +0 -0
  198. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache +0 -0
  199. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache_inline +0 -0
  200. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache_meta +0 -0
  201. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache_warnings +0 -0
  202. package/tui/build/dev/javascript/tui/gleam.mjs +1 -0
  203. package/tui/build/dev/javascript/tui/tui/prompt.mjs +521 -0
  204. package/tui/build/dev/javascript/tui/tui.mjs +334 -0
  205. package/tui/build/dev/javascript/tui/tui_ffi.mjs +32 -0
@@ -0,0 +1,868 @@
1
+ -module(gleam@erlang@process).
2
+ -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
3
+ -define(FILEPATH, "src/gleam/erlang/process.gleam").
4
+ -export([self/0, spawn/1, spawn_unlinked/1, unsafely_create_subject/2, new_name/1, named_subject/1, subject_name/1, 'receive'/2, receive_forever/1, new_selector/0, selector_receive/2, selector_receive_forever/1, map_selector/2, merge_selector/2, flush_messages/0, select_map/3, select/2, select_record/4, select_other/2, deselect/2, sleep/1, sleep_forever/0, is_alive/1, monitor/1, select_specific_monitor/3, select_monitors/2, select_trapped_exits/2, demonitor_process/1, deselect_specific_monitor/2, link/1, unlink/1, send_after/3, new_subject/0, cancel_timer/1, kill/1, send_exit/1, send_abnormal_exit/2, trap_exits/1, register/2, unregister/1, named/1, subject_owner/1, send/2, call/3, call_forever/2]).
5
+ -export_type([pid_/0, subject/1, name/1, do_not_leak/0, selector/1, exit_message/0, exit_reason/0, anything_selector_tag/0, process_monitor_flag/0, monitor/0, down/0, timer/0, cancelled/0, kill_flag/0]).
6
+
7
+ -if(?OTP_RELEASE >= 27).
8
+ -define(MODULEDOC(Str), -moduledoc(Str)).
9
+ -define(DOC(Str), -doc(Str)).
10
+ -else.
11
+ -define(MODULEDOC(Str), -compile([])).
12
+ -define(DOC(Str), -compile([])).
13
+ -endif.
14
+
15
+ -type pid_() :: any().
16
+
17
+ -opaque subject(DVB) :: {subject, pid_(), gleam@dynamic:dynamic_()} |
18
+ {named_subject, name(DVB)}.
19
+
20
+ -type name(DVC) :: any() | {gleam_phantom, DVC}.
21
+
22
+ -type do_not_leak() :: any().
23
+
24
+ -type selector(DVD) :: any() | {gleam_phantom, DVD}.
25
+
26
+ -type exit_message() :: {exit_message, pid_(), exit_reason()}.
27
+
28
+ -type exit_reason() :: normal | killed | {abnormal, gleam@dynamic:dynamic_()}.
29
+
30
+ -type anything_selector_tag() :: anything.
31
+
32
+ -type process_monitor_flag() :: process.
33
+
34
+ -type monitor() :: any().
35
+
36
+ -type down() :: {process_down, monitor(), pid_(), exit_reason()} |
37
+ {port_down, monitor(), gleam@erlang@port:port_(), exit_reason()}.
38
+
39
+ -type timer() :: any().
40
+
41
+ -type cancelled() :: timer_not_found | {cancelled, integer()}.
42
+
43
+ -type kill_flag() :: kill.
44
+
45
+ -file("src/gleam/erlang/process.gleam", 17).
46
+ ?DOC(" Get the `Pid` for the current process.\n").
47
+ -spec self() -> pid_().
48
+ self() ->
49
+ erlang:self().
50
+
51
+ -file("src/gleam/erlang/process.gleam", 36).
52
+ ?DOC(
53
+ " Create a new Erlang process that runs concurrently to the creator. In other\n"
54
+ " languages this might be called a fibre, a green thread, or a coroutine.\n"
55
+ "\n"
56
+ " The child process is linked to the creator process. When a process\n"
57
+ " terminates an exit signal is sent to all other processes that are linked to\n"
58
+ " it, causing the process to either terminate or have to handle the signal.\n"
59
+ " If you want an unlinked process use the `spawn_unlinked` function.\n"
60
+ "\n"
61
+ " More can be read about processes and links in the [Erlang documentation][1].\n"
62
+ "\n"
63
+ " [1]: https://www.erlang.org/doc/reference_manual/processes.html\n"
64
+ "\n"
65
+ " This function starts processes via the Erlang `proc_lib` module, and as\n"
66
+ " such they benefit from the functionality described in the\n"
67
+ " [`proc_lib` documentation](https://www.erlang.org/doc/apps/stdlib/proc_lib.html).\n"
68
+ ).
69
+ -spec spawn(fun(() -> any())) -> pid_().
70
+ spawn(Running) ->
71
+ proc_lib:spawn_link(Running).
72
+
73
+ -file("src/gleam/erlang/process.gleam", 53).
74
+ ?DOC(
75
+ " Create a new Erlang process that runs concurrently to the creator. In other\n"
76
+ " languages this might be called a fibre, a green thread, or a coroutine.\n"
77
+ "\n"
78
+ " Typically you want to create a linked process using the `spawn` function,\n"
79
+ " but creating an unlinked process may be occasionally useful.\n"
80
+ "\n"
81
+ " More can be read about processes and links in the [Erlang documentation][1].\n"
82
+ "\n"
83
+ " [1]: https://www.erlang.org/doc/reference_manual/processes.html\n"
84
+ "\n"
85
+ " This function starts processes via the Erlang `proc_lib` module, and as\n"
86
+ " such they benefit from the functionality described in the\n"
87
+ " [`proc_lib` documentation](https://www.erlang.org/doc/apps/stdlib/proc_lib.html).\n"
88
+ ).
89
+ -spec spawn_unlinked(fun(() -> any())) -> pid_().
90
+ spawn_unlinked(A) ->
91
+ proc_lib:spawn(A).
92
+
93
+ -file("src/gleam/erlang/process.gleam", 90).
94
+ ?DOC(false).
95
+ -spec unsafely_create_subject(pid_(), gleam@dynamic:dynamic_()) -> subject(any()).
96
+ unsafely_create_subject(Owner, Tag) ->
97
+ {subject, Owner, Tag}.
98
+
99
+ -file("src/gleam/erlang/process.gleam", 136).
100
+ ?DOC(
101
+ " Generate a new name that a process can register itself with using the\n"
102
+ " `register` function, and other processes can send messages to using\n"
103
+ " `named_subject`.\n"
104
+ "\n"
105
+ " The string argument is a prefix for the Erlang name. A unique suffix is\n"
106
+ " added to the prefix to make the name, removing the possibility of name\n"
107
+ " collisions.\n"
108
+ "\n"
109
+ " ## Safe use\n"
110
+ "\n"
111
+ " Use this function to create all the names your program needs when it\n"
112
+ " starts. **Never call this function dynamically** such as within a loop or\n"
113
+ " within a process within a supervision tree.\n"
114
+ "\n"
115
+ " Each time this function is called a new atom will be generated. Generating\n"
116
+ " too many atoms will result in the atom table getting filled and causing the\n"
117
+ " entire virtual machine to crash.\n"
118
+ ).
119
+ -spec new_name(binary()) -> name(any()).
120
+ new_name(Prefix) ->
121
+ gleam_erlang_ffi:new_name(Prefix).
122
+
123
+ -file("src/gleam/erlang/process.gleam", 143).
124
+ ?DOC(
125
+ " Create a subject for a name, which can be used to send and receive messages.\n"
126
+ "\n"
127
+ " All subjects created for the same name behave identically and can be used\n"
128
+ " interchangably.\n"
129
+ ).
130
+ -spec named_subject(name(DVK)) -> subject(DVK).
131
+ named_subject(Name) ->
132
+ {named_subject, Name}.
133
+
134
+ -file("src/gleam/erlang/process.gleam", 149).
135
+ ?DOC(" Get the name of a subject, returning an error if it doesn't have one.\n").
136
+ -spec subject_name(subject(DVN)) -> {ok, name(DVN)} | {error, nil}.
137
+ subject_name(Subject) ->
138
+ case Subject of
139
+ {named_subject, Name} ->
140
+ {ok, Name};
141
+
142
+ {subject, _, _} ->
143
+ {error, nil}
144
+ end.
145
+
146
+ -file("src/gleam/erlang/process.gleam", 247).
147
+ ?DOC(
148
+ " Receive a message that has been sent to current process using the `Subject`.\n"
149
+ "\n"
150
+ " If there is not an existing message for the `Subject` in the process'\n"
151
+ " mailbox or one does not arrive `within` the permitted timeout then the\n"
152
+ " `Error(Nil)` is returned.\n"
153
+ "\n"
154
+ " Only the process that is owner of the `Subject` can receive a message using\n"
155
+ " it. If a process that does not own the `Subject` attempts to receive with it\n"
156
+ " then it will not receive a message.\n"
157
+ "\n"
158
+ " To wait for messages from multiple `Subject`s at the same time see the\n"
159
+ " `Selector` type.\n"
160
+ "\n"
161
+ " The `within` parameter specifies the timeout duration in milliseconds.\n"
162
+ "\n"
163
+ " ## Panics\n"
164
+ "\n"
165
+ " This function will panic if a process tries to receive with a non-named\n"
166
+ " subject that it does not own.\n"
167
+ ).
168
+ -spec 'receive'(subject(DWB), integer()) -> {ok, DWB} | {error, nil}.
169
+ 'receive'(Subject, Timeout) ->
170
+ case Subject of
171
+ {named_subject, _} ->
172
+ gleam_erlang_ffi:'receive'(Subject, Timeout);
173
+
174
+ {subject, Owner, _} ->
175
+ case Owner =:= erlang:self() of
176
+ true ->
177
+ gleam_erlang_ffi:'receive'(Subject, Timeout);
178
+
179
+ false ->
180
+ erlang:error(#{gleam_error => panic,
181
+ message => <<"Cannot receive with a subject owned by another process"/utf8>>,
182
+ file => <<?FILEPATH/utf8>>,
183
+ module => <<"gleam/erlang/process"/utf8>>,
184
+ function => <<"receive"/utf8>>,
185
+ line => 257})
186
+ end
187
+ end.
188
+
189
+ -file("src/gleam/erlang/process.gleam", 272).
190
+ ?DOC(
191
+ " Receive a message that has been sent to current process using the `Subject`.\n"
192
+ "\n"
193
+ " Same as `receive` but waits forever and returns the message as is.\n"
194
+ ).
195
+ -spec receive_forever(subject(DWJ)) -> DWJ.
196
+ receive_forever(Subject) ->
197
+ gleam_erlang_ffi:'receive'(Subject).
198
+
199
+ -file("src/gleam/erlang/process.gleam", 301).
200
+ ?DOC(
201
+ " Create a new `Selector` which can be used to receive messages on multiple\n"
202
+ " `Subject`s at once.\n"
203
+ ).
204
+ -spec new_selector() -> selector(any()).
205
+ new_selector() ->
206
+ gleam_erlang_ffi:new_selector().
207
+
208
+ -file("src/gleam/erlang/process.gleam", 321).
209
+ ?DOC(
210
+ " Receive a message that has been sent to current process using any of the\n"
211
+ " `Subject`s that have been added to the `Selector` with the `select*`\n"
212
+ " functions.\n"
213
+ "\n"
214
+ " If there is not an existing message for the `Selector` in the process'\n"
215
+ " mailbox or one does not arrive `within` the permitted timeout then the\n"
216
+ " `Error(Nil)` is returned.\n"
217
+ "\n"
218
+ " Only the process that is owner of the `Subject`s can receive a message using\n"
219
+ " them. If a process that does not own the a `Subject` attempts to receive\n"
220
+ " with it then it will not receive a message.\n"
221
+ "\n"
222
+ " To wait forever for the next message rather than for a limited amount of\n"
223
+ " time see the `selector_receive_forever` function.\n"
224
+ "\n"
225
+ " The `within` parameter specifies the timeout duration in milliseconds.\n"
226
+ ).
227
+ -spec selector_receive(selector(DWN), integer()) -> {ok, DWN} | {error, nil}.
228
+ selector_receive(From, Within) ->
229
+ gleam_erlang_ffi:select(From, Within).
230
+
231
+ -file("src/gleam/erlang/process.gleam", 330).
232
+ ?DOC(
233
+ " Similar to the `select` function but will wait forever for a message to\n"
234
+ " arrive rather than timing out after a specified amount of time.\n"
235
+ ).
236
+ -spec selector_receive_forever(selector(DWR)) -> DWR.
237
+ selector_receive_forever(From) ->
238
+ gleam_erlang_ffi:select(From).
239
+
240
+ -file("src/gleam/erlang/process.gleam", 339).
241
+ ?DOC(
242
+ " Add a transformation function to a selector. When a message is received\n"
243
+ " using this selector the transformation function is applied to the message.\n"
244
+ "\n"
245
+ " This function can be used to change the type of messages received and may\n"
246
+ " be useful when combined with the `merge_selector` function.\n"
247
+ ).
248
+ -spec map_selector(selector(DWT), fun((DWT) -> DWV)) -> selector(DWV).
249
+ map_selector(A, B) ->
250
+ gleam_erlang_ffi:map_selector(A, B).
251
+
252
+ -file("src/gleam/erlang/process.gleam", 348).
253
+ ?DOC(
254
+ " Merge one selector into another, producing a selector that contains the\n"
255
+ " message handlers of both.\n"
256
+ "\n"
257
+ " If a subject is handled by both selectors the handler function of the\n"
258
+ " second selector is used.\n"
259
+ ).
260
+ -spec merge_selector(selector(DWX), selector(DWX)) -> selector(DWX).
261
+ merge_selector(A, B) ->
262
+ gleam_erlang_ffi:merge_selector(A, B).
263
+
264
+ -file("src/gleam/erlang/process.gleam", 384).
265
+ ?DOC(
266
+ " Discard all messages in the current process' mailbox.\n"
267
+ "\n"
268
+ " Warning: This function may cause other processes to crash if they sent a\n"
269
+ " message to the current process and are waiting for a response, so use with\n"
270
+ " caution.\n"
271
+ "\n"
272
+ " This function may be useful in tests.\n"
273
+ ).
274
+ -spec flush_messages() -> nil.
275
+ flush_messages() ->
276
+ gleam_erlang_ffi:flush_messages().
277
+
278
+ -file("src/gleam/erlang/process.gleam", 411).
279
+ ?DOC(
280
+ " Add a new `Subject` to the `Selector` so that its messages can be selected\n"
281
+ " from the receiver process inbox.\n"
282
+ "\n"
283
+ " The `mapping` function provided with the `Subject` can be used to convert\n"
284
+ " the type of messages received using this `Subject`. This is useful for when\n"
285
+ " you wish to add multiple `Subject`s to a `Selector` when they have differing\n"
286
+ " message types. If you do not wish to transform the incoming messages in any\n"
287
+ " way then the `identity` function can be given.\n"
288
+ "\n"
289
+ " See `deselect` to remove a subject from a selector.\n"
290
+ ).
291
+ -spec select_map(selector(DXI), subject(DXK), fun((DXK) -> DXI)) -> selector(DXI).
292
+ select_map(Selector, Subject, Transform) ->
293
+ Handler = fun(Message) -> Transform(erlang:element(2, Message)) end,
294
+ case Subject of
295
+ {named_subject, Name} ->
296
+ gleam_erlang_ffi:insert_selector_handler(
297
+ Selector,
298
+ {Name, 2},
299
+ Handler
300
+ );
301
+
302
+ {subject, _, Tag} ->
303
+ gleam_erlang_ffi:insert_selector_handler(
304
+ Selector,
305
+ {Tag, 2},
306
+ Handler
307
+ )
308
+ end.
309
+
310
+ -file("src/gleam/erlang/process.gleam", 393).
311
+ ?DOC(
312
+ " Add a new `Subject` to the `Selector` so that its messages can be selected\n"
313
+ " from the receiver process inbox.\n"
314
+ "\n"
315
+ " See `select_map` to add subjects of a different message type.\n"
316
+ "\n"
317
+ " See `deselect` to remove a subject from a selector.\n"
318
+ ).
319
+ -spec select(selector(DXE), subject(DXE)) -> selector(DXE).
320
+ select(Selector, Subject) ->
321
+ select_map(Selector, Subject, fun(X) -> X end).
322
+
323
+ -file("src/gleam/erlang/process.gleam", 447).
324
+ ?DOC(
325
+ " Add a handler to a selector for tuple messages with a given tag in the\n"
326
+ " first position followed by a given number of fields.\n"
327
+ "\n"
328
+ " Typically you want to use the `select` function with a `Subject` instead,\n"
329
+ " but this function may be useful if you need to receive messages sent from\n"
330
+ " other BEAM languages that do not use the `Subject` type.\n"
331
+ "\n"
332
+ " This will not select messages sent via a subject even if the message has\n"
333
+ " the same tag in the first position. This is because when a message is sent\n"
334
+ " via a subject a new tag is used that is unique and specific to that subject.\n"
335
+ ).
336
+ -spec select_record(
337
+ selector(DXS),
338
+ any(),
339
+ integer(),
340
+ fun((gleam@dynamic:dynamic_()) -> DXS)
341
+ ) -> selector(DXS).
342
+ select_record(Selector, Tag, Arity, Transform) ->
343
+ gleam_erlang_ffi:insert_selector_handler(
344
+ Selector,
345
+ {Tag, Arity + 1},
346
+ Transform
347
+ ).
348
+
349
+ -file("src/gleam/erlang/process.gleam", 467).
350
+ ?DOC(
351
+ " Add a catch-all handler to a selector that will be used when no other\n"
352
+ " handler in a selector is suitable for a given message.\n"
353
+ "\n"
354
+ " This may be useful for when you want to ensure that any message in the inbox\n"
355
+ " is handled, or when you need to handle messages from other BEAM languages\n"
356
+ " which do not use subjects or record format messages.\n"
357
+ ).
358
+ -spec select_other(selector(DXW), fun((gleam@dynamic:dynamic_()) -> DXW)) -> selector(DXW).
359
+ select_other(Selector, Handler) ->
360
+ gleam_erlang_ffi:insert_selector_handler(Selector, anything, Handler).
361
+
362
+ -file("src/gleam/erlang/process.gleam", 426).
363
+ ?DOC(
364
+ " Remove a new `Subject` from the `Selector` so that its messages will not be\n"
365
+ " selected from the receiver process inbox.\n"
366
+ ).
367
+ -spec deselect(selector(DXN), subject(any())) -> selector(DXN).
368
+ deselect(Selector, Subject) ->
369
+ case Subject of
370
+ {named_subject, Name} ->
371
+ gleam_erlang_ffi:remove_selector_handler(Selector, {Name, 2});
372
+
373
+ {subject, _, Tag} ->
374
+ gleam_erlang_ffi:remove_selector_handler(Selector, {Tag, 2})
375
+ end.
376
+
377
+ -file("src/gleam/erlang/process.gleam", 491).
378
+ ?DOC(
379
+ " Suspends the process calling this function for the specified number of\n"
380
+ " milliseconds.\n"
381
+ ).
382
+ -spec sleep(integer()) -> nil.
383
+ sleep(A) ->
384
+ gleam_erlang_ffi:sleep(A).
385
+
386
+ -file("src/gleam/erlang/process.gleam", 498).
387
+ ?DOC(
388
+ " Suspends the process forever! This may be useful for suspending the main\n"
389
+ " process in a Gleam program when it has no more work to do but we want other\n"
390
+ " processes to continue to work.\n"
391
+ ).
392
+ -spec sleep_forever() -> nil.
393
+ sleep_forever() ->
394
+ gleam_erlang_ffi:sleep_forever().
395
+
396
+ -file("src/gleam/erlang/process.gleam", 507).
397
+ ?DOC(
398
+ " Check to see whether the process for a given `Pid` is alive.\n"
399
+ "\n"
400
+ " See the [Erlang documentation][1] for more information.\n"
401
+ "\n"
402
+ " [1]: http://erlang.org/doc/man/erlang.html#is_process_alive-1\n"
403
+ ).
404
+ -spec is_alive(pid_()) -> boolean().
405
+ is_alive(A) ->
406
+ erlang:is_process_alive(A).
407
+
408
+ -file("src/gleam/erlang/process.gleam", 537).
409
+ ?DOC(
410
+ " Start monitoring a process so that when the monitored process exits a\n"
411
+ " message is sent to the monitoring process.\n"
412
+ "\n"
413
+ " The message is only sent once, when the target process exits. If the\n"
414
+ " process was not alive when this function is called the message will never\n"
415
+ " be received.\n"
416
+ "\n"
417
+ " The down message can be received with a selector and the\n"
418
+ " `select_monitors` function.\n"
419
+ "\n"
420
+ " The process can be demonitored with the `demonitor_process` function.\n"
421
+ ).
422
+ -spec monitor(pid_()) -> monitor().
423
+ monitor(Pid) ->
424
+ erlang:monitor(process, Pid).
425
+
426
+ -file("src/gleam/erlang/process.gleam", 550).
427
+ ?DOC(
428
+ " Select for a message sent for a given monitor.\n"
429
+ "\n"
430
+ " Each monitor handler added to a selector has a select performance cost,\n"
431
+ " so prefer [`select_monitors`](#select_monitors) if you are select\n"
432
+ " for multiple monitors.\n"
433
+ "\n"
434
+ " The handler can be removed from the selector later using\n"
435
+ " [`deselect_specific_monitor`](#deselect_specific_monitor).\n"
436
+ ).
437
+ -spec select_specific_monitor(selector(DYI), monitor(), fun((down()) -> DYI)) -> selector(DYI).
438
+ select_specific_monitor(Selector, Monitor, Mapping) ->
439
+ gleam_erlang_ffi:insert_selector_handler(Selector, Monitor, Mapping).
440
+
441
+ -file("src/gleam/erlang/process.gleam", 564).
442
+ ?DOC(
443
+ " Select for any messages sent for any monitors set up by the select process.\n"
444
+ "\n"
445
+ " If you want to select for a specific message then use \n"
446
+ " [`select_specific_monitor`](#select_specific_monitor), but this\n"
447
+ " function is preferred if you need to select for multiple monitors.\n"
448
+ ).
449
+ -spec select_monitors(selector(DYL), fun((down()) -> DYL)) -> selector(DYL).
450
+ select_monitors(Selector, Mapping) ->
451
+ gleam_erlang_ffi:insert_selector_handler(
452
+ Selector,
453
+ {erlang:binary_to_atom(<<"DOWN"/utf8>>), 5},
454
+ fun(Message) -> Mapping(gleam_erlang_ffi:cast_down_message(Message)) end
455
+ ).
456
+
457
+ -file("src/gleam/erlang/process.gleam", 364).
458
+ ?DOC(
459
+ " Add a handler for trapped exit messages. In order for these messages to be\n"
460
+ " sent to the process when a linked process exits the process must call the\n"
461
+ " `trap_exit` beforehand.\n"
462
+ ).
463
+ -spec select_trapped_exits(selector(DXB), fun((exit_message()) -> DXB)) -> selector(DXB).
464
+ select_trapped_exits(Selector, Handler) ->
465
+ Tag = erlang:binary_to_atom(<<"EXIT"/utf8>>),
466
+ Handler@1 = fun(Message) ->
467
+ Handler(
468
+ {exit_message,
469
+ erlang:element(2, Message),
470
+ gleam_erlang_ffi:cast_exit_reason(erlang:element(3, Message))}
471
+ )
472
+ end,
473
+ gleam_erlang_ffi:insert_selector_handler(Selector, {Tag, 3}, Handler@1).
474
+
475
+ -file("src/gleam/erlang/process.gleam", 585).
476
+ ?DOC(
477
+ " Remove the monitor for a process so that when the monitor process exits a\n"
478
+ " `Down` message is not sent to the monitoring process.\n"
479
+ "\n"
480
+ " If the message has already been sent it is removed from the monitoring\n"
481
+ " process' mailbox.\n"
482
+ ).
483
+ -spec demonitor_process(monitor()) -> nil.
484
+ demonitor_process(Monitor) ->
485
+ gleam_erlang_ffi:demonitor(Monitor),
486
+ nil.
487
+
488
+ -file("src/gleam/erlang/process.gleam", 598).
489
+ ?DOC(
490
+ " Remove a `Monitor` from a `Selector` prevoiusly added by\n"
491
+ " [`select_specific_monitor`](#select_specific_monitor). If\n"
492
+ " the `Monitor` is not in the `Selector` it will be returned\n"
493
+ " unchanged.\n"
494
+ ).
495
+ -spec deselect_specific_monitor(selector(DYO), monitor()) -> selector(DYO).
496
+ deselect_specific_monitor(Selector, Monitor) ->
497
+ gleam_erlang_ffi:remove_selector_handler(Selector, Monitor).
498
+
499
+ -file("src/gleam/erlang/process.gleam", 729).
500
+ ?DOC(
501
+ " Creates a link between the calling process and another process.\n"
502
+ "\n"
503
+ " When a process crashes any linked processes will also crash. This is useful\n"
504
+ " to ensure that groups of processes that depend on each other all either\n"
505
+ " succeed or fail together.\n"
506
+ "\n"
507
+ " Returns `True` if the link was created successfully, returns `False` if the\n"
508
+ " process was not alive and as such could not be linked.\n"
509
+ ).
510
+ -spec link(pid_()) -> boolean().
511
+ link(Pid) ->
512
+ gleam_erlang_ffi:link(Pid).
513
+
514
+ -file("src/gleam/erlang/process.gleam", 736).
515
+ ?DOC(" Removes any existing link between the caller process and the target process.\n").
516
+ -spec unlink(pid_()) -> nil.
517
+ unlink(Pid) ->
518
+ erlang:unlink(Pid),
519
+ nil.
520
+
521
+ -file("src/gleam/erlang/process.gleam", 751).
522
+ ?DOC(" Send a message over a channel after a specified number of milliseconds.\n").
523
+ -spec send_after(subject(DZK), integer(), DZK) -> timer().
524
+ send_after(Subject, Delay, Message) ->
525
+ case Subject of
526
+ {named_subject, Name} ->
527
+ erlang:send_after(Delay, Name, {Name, Message});
528
+
529
+ {subject, Owner, Tag} ->
530
+ erlang:send_after(Delay, Owner, {Tag, Message})
531
+ end.
532
+
533
+ -file("src/gleam/erlang/process.gleam", 158).
534
+ ?DOC(" Create a new `Subject` owned by the current process.\n").
535
+ -spec new_subject() -> subject(any()).
536
+ new_subject() ->
537
+ {subject, erlang:self(), gleam_erlang_ffi:identity(erlang:make_ref())}.
538
+
539
+ -file("src/gleam/erlang/process.gleam", 781).
540
+ ?DOC(" Cancel a given timer, causing it not to trigger if it has not done already.\n").
541
+ -spec cancel_timer(timer()) -> cancelled().
542
+ cancel_timer(Timer) ->
543
+ case gleam@dynamic@decode:run(
544
+ erlang:cancel_timer(Timer),
545
+ {decoder, fun gleam@dynamic@decode:decode_int/1}
546
+ ) of
547
+ {ok, I} ->
548
+ {cancelled, I};
549
+
550
+ {error, _} ->
551
+ timer_not_found
552
+ end.
553
+
554
+ -file("src/gleam/erlang/process.gleam", 805).
555
+ ?DOC(
556
+ " Send an untrappable `kill` exit signal to the target process.\n"
557
+ "\n"
558
+ " See the documentation for the Erlang [`erlang:exit`][1] function for more\n"
559
+ " information.\n"
560
+ "\n"
561
+ " [1]: https://erlang.org/doc/man/erlang.html#exit-1\n"
562
+ ).
563
+ -spec kill(pid_()) -> nil.
564
+ kill(Pid) ->
565
+ erlang:exit(Pid, kill),
566
+ nil.
567
+
568
+ -file("src/gleam/erlang/process.gleam", 821).
569
+ ?DOC(
570
+ " Sends an exit signal to a process, indicating that the process is to shut\n"
571
+ " down.\n"
572
+ "\n"
573
+ " See the [Erlang documentation][1] for more information.\n"
574
+ "\n"
575
+ " [1]: http://erlang.org/doc/man/erlang.html#exit-2\n"
576
+ ).
577
+ -spec send_exit(pid_()) -> nil.
578
+ send_exit(Pid) ->
579
+ erlang:exit(Pid, normal),
580
+ nil.
581
+
582
+ -file("src/gleam/erlang/process.gleam", 833).
583
+ ?DOC(
584
+ " Sends an exit signal to a process, indicating that the process is to shut\n"
585
+ " down due to an abnormal reason such as a failure.\n"
586
+ "\n"
587
+ " See the [Erlang documentation][1] for more information.\n"
588
+ "\n"
589
+ " [1]: http://erlang.org/doc/man/erlang.html#exit-2\n"
590
+ ).
591
+ -spec send_abnormal_exit(pid_(), any()) -> nil.
592
+ send_abnormal_exit(Pid, Reason) ->
593
+ erlang:exit(Pid, Reason),
594
+ nil.
595
+
596
+ -file("src/gleam/erlang/process.gleam", 849).
597
+ ?DOC(
598
+ " Set whether the current process is to trap exit signals or not.\n"
599
+ "\n"
600
+ " When not trapping exits if a linked process crashes the exit signal\n"
601
+ " propagates to the process which will also crash.\n"
602
+ " This is the normal behaviour before this function is called.\n"
603
+ "\n"
604
+ " When trapping exits (after this function is called) if a linked process\n"
605
+ " crashes an exit message is sent to the process instead. These messages can\n"
606
+ " be handled with the `select_trapped_exits` function.\n"
607
+ ).
608
+ -spec trap_exits(boolean()) -> nil.
609
+ trap_exits(A) ->
610
+ gleam_erlang_ffi:trap_exits(A).
611
+
612
+ -file("src/gleam/erlang/process.gleam", 860).
613
+ ?DOC(
614
+ " Register a process under a given name, allowing it to be looked up using\n"
615
+ " the `named` function.\n"
616
+ "\n"
617
+ " This function will return an error under the following conditions:\n"
618
+ " - The process for the pid no longer exists.\n"
619
+ " - The name has already been registered.\n"
620
+ " - The process already has a name.\n"
621
+ ).
622
+ -spec register(pid_(), name(any())) -> {ok, nil} | {error, nil}.
623
+ register(Pid, Name) ->
624
+ gleam_erlang_ffi:register_process(Pid, Name).
625
+
626
+ -file("src/gleam/erlang/process.gleam", 871).
627
+ ?DOC(
628
+ " Un-register a process name, after which the process can no longer be looked\n"
629
+ " up by that name, and both the name and the process can be re-used in other\n"
630
+ " registrations.\n"
631
+ "\n"
632
+ " It is possible to un-register process that are not from your application,\n"
633
+ " including those from Erlang/OTP itself. This is not recommended and will\n"
634
+ " likely result in undesirable behaviour and crashes.\n"
635
+ ).
636
+ -spec unregister(name(any())) -> {ok, nil} | {error, nil}.
637
+ unregister(Name) ->
638
+ gleam_erlang_ffi:unregister_process(Name).
639
+
640
+ -file("src/gleam/erlang/process.gleam", 876).
641
+ ?DOC(" Look up a process by registered name, returning the pid if it exists.\n").
642
+ -spec named(name(any())) -> {ok, pid_()} | {error, nil}.
643
+ named(Name) ->
644
+ gleam_erlang_ffi:process_named(Name).
645
+
646
+ -file("src/gleam/erlang/process.gleam", 168).
647
+ ?DOC(
648
+ " Get the owner process for a subject, which is the process that will\n"
649
+ " receive any messages sent using the subject.\n"
650
+ "\n"
651
+ " If the subject was created from a name and no process is currently\n"
652
+ " registered with that name then this function will return an error.\n"
653
+ ).
654
+ -spec subject_owner(subject(any())) -> {ok, pid_()} | {error, nil}.
655
+ subject_owner(Subject) ->
656
+ case Subject of
657
+ {named_subject, Name} ->
658
+ gleam_erlang_ffi:process_named(Name);
659
+
660
+ {subject, Pid, _} ->
661
+ {ok, Pid}
662
+ end.
663
+
664
+ -file("src/gleam/erlang/process.gleam", 214).
665
+ ?DOC(
666
+ " Send a message to a process using a `Subject`. The message must be of the\n"
667
+ " type that the `Subject` accepts.\n"
668
+ "\n"
669
+ " This function does not wait for the `Subject` owner process to call the\n"
670
+ " `receive` function, instead it returns once the message has been placed in\n"
671
+ " the process' mailbox.\n"
672
+ " \n"
673
+ " # Named Subjects\n"
674
+ " \n"
675
+ " If this function is called on a named subject for which a process has not been \n"
676
+ " registered, it will simply drop the message as there's no mailbox to send it to.\n"
677
+ "\n"
678
+ " # Panics\n"
679
+ "\n"
680
+ " This function will panic when sending to a named subject if no process is\n"
681
+ " currently registed under that name.\n"
682
+ "\n"
683
+ " # Ordering\n"
684
+ "\n"
685
+ " If process P1 sends two messages to process P2 it is guaranteed that process\n"
686
+ " P1 will receive the messages in the order they were sent.\n"
687
+ "\n"
688
+ " If you wish to receive the messages in a different order you can send them\n"
689
+ " on two different subjects and the receiver function can call the `receive`\n"
690
+ " function for each subject in the desired order, or you can write some Erlang\n"
691
+ " code to perform a selective receive.\n"
692
+ "\n"
693
+ " # Examples\n"
694
+ "\n"
695
+ " ```gleam\n"
696
+ " let subject = new_subject()\n"
697
+ " send(subject, \"Hello, Joe!\")\n"
698
+ " ```\n"
699
+ ).
700
+ -spec send(subject(DVZ), DVZ) -> nil.
701
+ send(Subject, Message) ->
702
+ case Subject of
703
+ {subject, Pid, Tag} ->
704
+ erlang:send(Pid, {Tag, Message});
705
+
706
+ {named_subject, Name} ->
707
+ Pid@2 = case gleam_erlang_ffi:process_named(Name) of
708
+ {ok, Pid@1} -> Pid@1;
709
+ _assert_fail ->
710
+ erlang:error(#{gleam_error => let_assert,
711
+ message => <<"Sending to unregistered name"/utf8>>,
712
+ file => <<?FILEPATH/utf8>>,
713
+ module => <<"gleam/erlang/process"/utf8>>,
714
+ function => <<"send"/utf8>>,
715
+ line => 220,
716
+ value => _assert_fail,
717
+ start => 8194,
718
+ 'end' => 8226,
719
+ pattern_start => 8205,
720
+ pattern_end => 8212})
721
+ end,
722
+ erlang:send(Pid@2, {Name, Message})
723
+ end,
724
+ nil.
725
+
726
+ -file("src/gleam/erlang/process.gleam", 605).
727
+ -spec perform_call(
728
+ subject(DYR),
729
+ fun((subject(DYT)) -> DYR),
730
+ fun((selector(DYT)) -> {ok, DYT} | {error, nil})
731
+ ) -> DYT.
732
+ perform_call(Subject, Make_request, Run_selector) ->
733
+ Reply_subject = new_subject(),
734
+ Callee@1 = case subject_owner(Subject) of
735
+ {ok, Callee} -> Callee;
736
+ _assert_fail ->
737
+ erlang:error(#{gleam_error => let_assert,
738
+ message => <<"Callee subject had no owner"/utf8>>,
739
+ file => <<?FILEPATH/utf8>>,
740
+ module => <<"gleam/erlang/process"/utf8>>,
741
+ function => <<"perform_call"/utf8>>,
742
+ line => 611,
743
+ value => _assert_fail,
744
+ start => 21173,
745
+ 'end' => 21219,
746
+ pattern_start => 21184,
747
+ pattern_end => 21194})
748
+ end,
749
+ Monitor = monitor(Callee@1),
750
+ send(Subject, Make_request(Reply_subject)),
751
+ Reply = begin
752
+ _pipe = gleam_erlang_ffi:new_selector(),
753
+ _pipe@1 = select(_pipe, Reply_subject),
754
+ _pipe@2 = select_specific_monitor(
755
+ _pipe@1,
756
+ Monitor,
757
+ fun(Down) -> erlang:error(#{gleam_error => panic,
758
+ message => (<<"callee exited: "/utf8,
759
+ (gleam@string:inspect(Down))/binary>>),
760
+ file => <<?FILEPATH/utf8>>,
761
+ module => <<"gleam/erlang/process"/utf8>>,
762
+ function => <<"perform_call"/utf8>>,
763
+ line => 626}) end
764
+ ),
765
+ Run_selector(_pipe@2)
766
+ end,
767
+ Reply@2 = case Reply of
768
+ {ok, Reply@1} -> Reply@1;
769
+ _assert_fail@1 ->
770
+ erlang:error(#{gleam_error => let_assert,
771
+ message => <<"callee did not send reply before timeout"/utf8>>,
772
+ file => <<?FILEPATH/utf8>>,
773
+ module => <<"gleam/erlang/process"/utf8>>,
774
+ function => <<"perform_call"/utf8>>,
775
+ line => 630,
776
+ value => _assert_fail@1,
777
+ start => 21766,
778
+ 'end' => 21794,
779
+ pattern_start => 21777,
780
+ pattern_end => 21786})
781
+ end,
782
+ demonitor_process(Monitor),
783
+ Reply@2.
784
+
785
+ -file("src/gleam/erlang/process.gleam", 695).
786
+ ?DOC(
787
+ " Send a message to a process and wait a given number of milliseconds for a\n"
788
+ " reply.\n"
789
+ "\n"
790
+ " ## Panics\n"
791
+ "\n"
792
+ " This function will panic under the following circumstances:\n"
793
+ " - The callee process exited prior to sending a reply.\n"
794
+ " - The callee process did not send a reply within the permitted amount of\n"
795
+ " time.\n"
796
+ " - The subject is a named subject but no process is registered with that\n"
797
+ " name.\n"
798
+ "\n"
799
+ " ## Examples\n"
800
+ "\n"
801
+ " ```gleam\n"
802
+ " pub type Message {\n"
803
+ " // This message variant is to be used with `call`.\n"
804
+ " // The `reply` field contains a subject that the reply message will be\n"
805
+ " // sent over.\n"
806
+ " SayHello(reply_to: Subject(String), name: String)\n"
807
+ " }\n"
808
+ " \n"
809
+ " // Typically we make public functions that hide the details of a process'\n"
810
+ " // message-based API.\n"
811
+ " pub fn say_hello(subject: Subject(Message), name: String) -> String {\n"
812
+ " // The `SayHello` message constructor is given _partially applied_ with\n"
813
+ " // all the arguments except the reply subject, which will be supplied by\n"
814
+ " // the `call` function itself before sending the message.\n"
815
+ " process.call(subject, 100, SayHello(_, name))\n"
816
+ " }\n"
817
+ "\n"
818
+ " // This is the message handling logic used by the process that owns the\n"
819
+ " // subject, and so receives the messages. In a real project it would be\n"
820
+ " // within a process or some higher level abstraction like an actor, but for\n"
821
+ " // this demonstration that has been omitted.\n"
822
+ " pub fn handle_message(message: Message) -> Nil {\n"
823
+ " case message {\n"
824
+ " SayHello(reply:, name:) -> {\n"
825
+ " let data = \"Hello, \" <> name <> \"!\"\n"
826
+ " // The reply subject is used to send the response back.\n"
827
+ " // If the receiver process does not sent a reply in time then the\n"
828
+ " // caller will crash.\n"
829
+ " process.send(reply, data)\n"
830
+ " }\n"
831
+ " }\n"
832
+ " }\n"
833
+ "\n"
834
+ " // Here is what it looks like using the functional API to call the process.\n"
835
+ " pub fn run(subject: Subject(Message)) {\n"
836
+ " say_hello(subject, \"Lucy\")\n"
837
+ " // -> \"Hello, Lucy!\"\n"
838
+ " say_hello(subject, \"Nubi\")\n"
839
+ " // -> \"Hello, Nubi!\"\n"
840
+ " }\n"
841
+ " ```\n"
842
+ ).
843
+ -spec call(subject(DYY), integer(), fun((subject(DZA)) -> DYY)) -> DZA.
844
+ call(Subject, Timeout, Make_request) ->
845
+ perform_call(
846
+ Subject,
847
+ Make_request,
848
+ fun(_capture) -> gleam_erlang_ffi:select(_capture, Timeout) end
849
+ ).
850
+
851
+ -file("src/gleam/erlang/process.gleam", 712).
852
+ ?DOC(
853
+ " Send a message to a process and wait for a reply.\n"
854
+ "\n"
855
+ " # Panics\n"
856
+ "\n"
857
+ " This function will panic under the following circumstances:\n"
858
+ " - The callee process exited prior to sending a reply.\n"
859
+ " - The subject is a named subject but no process is registered with that\n"
860
+ " name.\n"
861
+ ).
862
+ -spec call_forever(subject(DZC), fun((subject(DZE)) -> DZC)) -> DZE.
863
+ call_forever(Subject, Make_request) ->
864
+ perform_call(
865
+ Subject,
866
+ Make_request,
867
+ fun(S) -> {ok, gleam_erlang_ffi:select(S)} end
868
+ ).