#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_SUPPORT_COLLECTIONS_CONCURRENTSET_H #define NUCLEX_SUPPORT_COLLECTIONS_CONCURRENTSET_H #include "Nuclex/Support/Config.h" #include // for std::size_t namespace Nuclex { namespace Support { namespace Collections { // ------------------------------------------------------------------------------------------- // /// Set that can safely be used from multiple threads /// Type of the key the set will keep track of template class ConcurrentSet { /// Destroys the concurrent set public: virtual ~ConcurrentSet() = default; /// Tries to insert a key into the set in a thread-safe manner /// Key that will be inserted into the set /// True if the key was inserted, false if the key already existed public: virtual bool TryInsert(const TKey &key) = 0; /// Tries to remove a key from the set /// Key that will be removed from the set /// /// True if the key was removed from the set, false if the key didn't exist (anymore?) /// public: virtual bool TryRemove(const TKey &key) = 0; /// Counts the numebr of keys currently in the set /// /// The approximate number of keys that had been in the set during the call /// public: virtual std::size_t Count() const = 0; /// Checks if the set is empty /// True if the set had been empty during the call public: virtual bool IsEmpty() const = 0; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Collections #endif // NUCLEX_SUPPORT_COLLECTIONS_CONCURRENTSET_H