Skip to content

Instantly share code, notes, and snippets.

@Porges
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save Porges/b9a318bc1f98dd16184a to your computer and use it in GitHub Desktop.

Select an option

Save Porges/b9a318bc1f98dd16184a to your computer and use it in GitHub Desktop.
open System
open System.Threading
type OnceLazy (action : unit -> unit) =
let it = Lazy(action, LazyThreadSafetyMode.ExecutionAndPublication)
member this.Force() = it.Force()
type Once (action : unit -> unit) =
let mutable performed = 0
member this.Force() =
if Interlocked.CompareExchange(&performed, 1, 0) = 0
then action()
let main =
let o = Once(fun () -> printfn "hello!")
o.Force()
o.Force()
@Blackmart994
Copy link

Open ....n type xnxx its works ...Really

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment