github.com/tursom/GoCollections@v0.3.10/concurrent/Once.go (about) 1 /* 2 * Copyright (c) 2022 tursom. All rights reserved. 3 * Use of this source code is governed by a GPL-3 4 * license that can be found in the LICENSE file. 5 */ 6 7 package concurrent 8 9 import ( 10 "sync" 11 "unsafe" 12 ) 13 14 type ( 15 Once sync.Once 16 ) 17 18 func (o *Once) Do(f func()) { 19 (*sync.Once)(o).Do(f) 20 } 21 22 func (o *Once) IsDone() bool { 23 i := *(*uint32)(unsafe.Pointer(o)) 24 return i != 0 25 }