...

Source file src/solace.dev/go/messaging/pkg/solace/message/disposable.go

Documentation: solace.dev/go/messaging/pkg/solace/message

     1  // pubsubplus-go-client
     2  //
     3  // Copyright 2021-2024 Solace Corporation. All rights reserved.
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  // http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  
    17  package message
    18  
    19  // Disposable implies that the implementing data structure needs to free
    20  // the underlying resources. This is done with the Dispose function. It is optional to use
    21  // this function to free the underlying resources because any implementing data structure must attempt
    22  // to free the underlying resources using a finalizer. For
    23  // performance purposes, we recommend to explicitly free the underlying resources
    24  // before garbage collection runs.
    25  type Disposable interface {
    26  	// Dispose frees all the underlying resources of the Disposable instance.
    27  	// Dispose is idempotent, and removes any redundant finalizers on the
    28  	// instance and substantially improves garbage-collection performance.
    29  	// This function is thread-safe, and subsequent calls to Dispose
    30  	// block and wait for the first call to complete. Additional calls
    31  	// return immediately. The instance is considered unusable after Dispose
    32  	// has been called.
    33  	Dispose()
    34  
    35  	// IsDisposed checks if the Disposable instance has been disposed by
    36  	// a call to Dispose. IsDisposeed returns true if Dispose has been called,
    37  	// otherwise false if it is still usable. Dispose may or may not have returned.
    38  	// The instance is considered unusable if IsDisposed returns true.
    39  	IsDisposed() bool
    40  }
    41