@@ -715,17 +715,30 @@ pub fn send_abnormal_exit(pid: Pid, reason: String) -> Nil {
715715@ external ( erlang , "gleam_erlang_ffi" , "trap_exits" )
716716pub fn trap_exits ( a : Bool ) -> Nil
717717
718- // TODO: test
719- // TODO: document
718+ /// Register a process under a given name, allowing it to be looked up using
719+ /// the `named` function.
720+ ///
721+ /// This function will return an error under the following conditions:
722+ /// - The process for the pid no longer exists.
723+ /// - The name has already been registered.
724+ /// - The process already has a name.
725+ /// - The name is the atom `undefined`, which is reserved by Erlang.
726+ ///
720727@ external ( erlang , "gleam_erlang_ffi" , "register_process" )
721728pub fn register ( pid : Pid , name : Atom ) -> Result ( Nil , Nil )
722729
723- // TODO: test
724- // TODO: document
730+ /// Un-register a process name, after which the process can no longer be looked
731+ /// up by that name, and both the name and the process can be re-used in other
732+ /// registrations.
733+ ///
734+ /// It is possible to un-register process that are not from your application,
735+ /// including those from Erlang/OTP itself. This is not recommended and will
736+ /// likely result in undesirable behaviour and crashes.
737+ ///
725738@ external ( erlang , "gleam_erlang_ffi" , "unregister_process" )
726739pub fn unregister ( name : Atom ) -> Result ( Nil , Nil )
727740
728- // TODO: test
729- // TODO: document
741+ /// Look up a process by name, returning the pid if it exists.
742+ ///
730743@ external ( erlang , "gleam_erlang_ffi" , "process_named" )
731744pub fn named ( name : Atom ) -> Result ( Pid , Nil )
0 commit comments