Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/compiler/PervEnv/OS/at-exit.sml
ViewVC logotype

View of /sml/trunk/src/compiler/PervEnv/OS/at-exit.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 94 - (download) (annotate)
Tue May 12 21:56:22 1998 UTC (21 years, 10 months ago) by monnier
File size: 931 byte(s)
This commit was generated by cvs2svn to compensate for changes in r93,
which included commits to RCS files with non-trunk default branches.
(* at-exit.sml
 *
 * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
 *
 * The (generic) support for the OS.Process.atExit function.
 *)

structure AtExit : sig

    val atExit : (unit -> unit) -> unit

  end = struct

    structure CU = CleanUp

    val hooks = ref ([] : (unit -> unit) list)

  (* Note that the semantics of atExit require that calls to exit
   * in an atExit action cause the remaining atExit actions to be
   * performed.  
   *)
    fun doAtExit () = (case !hooks
	   of [] => ()
	    | (f::r) => (hooks := r;  f() handle _ => (); doAtExit())
	  (* end case *))

    fun cleaner CU.AtExit = doAtExit()
      | cleaner CU.AtExportFn = hooks := []
      | cleaner _ = ()

    val _ = CU.addCleaner ("OS.Process", [CU.AtExit, CU.AtExportFn], cleaner)

    fun atExit hook = hooks := hook :: !hooks

  end;

(*
 * $Log: at-exit.sml,v $
 * Revision 1.1.1.1  1998/04/08 18:39:56  george
 * Version 110.5
 *
 *)


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0