Documentation ¶
Overview ¶
Package openclose provides a synchronization primitive (similar to a semaphore)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenClose ¶
type OpenClose struct {
// contains filtered or unexported fields
}
OpenClose represents a synchronization primitive (similar to a semaphore) that can be used to signal that an operation has started. All methods are safe to call from multiple goroutines.
func (*OpenClose) IsCloseRequested ¶
IsCloseRequested returns true if the OpenClose is requested to be closed.
func (*OpenClose) Open ¶
Open opens the OpenClose and returns a function that can be used to close it. If the OpenClose is already opened or closed, it returns false and a nil function. If fn is not nil, it will be called before the OpenClose is opened.
func (*OpenClose) RequestClose ¶
RequestClose requests that the OpenClose be closed and calls fn if close has not been requested. It will run fn even if the OpenClose is already closed from Open callback, but it was not requested to be closed.
func (*OpenClose) RequestCloseWait ¶
RequestCloseWait requests that the OpenClose be closed and calls fn if close has not been requested. It will run fn even if the OpenClose is already closed from Open callback, but it was not requested to be closed. It waits until the Open callback is called and the OpenClose is closed.