36 template<
typename type_t>
64 for (
const auto& item : items)
69 for (
const auto& item : collection)
83 [[nodiscard]]
auto is_empty() const noexcept ->
bool {
return count_ == 0;}
88 [[nodiscard]]
auto is_read_only() const noexcept ->
bool override {
return false;}
124 array[array_index +
i] = items[
i];
133 return items.get_enumerator();
142 for (
const auto& [thread_id, storage] : storages_)
145 return result.to_array();
157 current_local_storage()->enqueue(item);
166 if (current_local_storage()->
count())
return current_local_storage()->try_peek(item);
168 for (
auto& [thread_id, storage] : storages_) {
169 if (storage->count())
return storage->try_peek(item);
179 if (current_local_storage()->
count()) {
180 auto result = current_local_storage()->try_dequeue(item);
187 for (
auto& [thread_id, storage] : storages_) {
188 if (storage->count()) {
189 auto result = storage->try_dequeue(item);
202 [[nodiscard]]
auto contains(
const_reference item)
const noexcept ->
bool override {
return false;}
204 [[nodiscard]]
auto sync_root() const noexcept -> const
object&
override {
return storages_;}
207 if (thread_local_storages_.contains_key(instance_id_))
return thread_local_storages_[instance_id_];
211 auto storage = storages_[id].get();
212 thread_local_storages_[instance_id_] = storage;
215 return thread_local_storages_[instance_id_];
218 inline static thread_local xtd::collections::generic::dictionary<xtd::uint64, local_storage_type> thread_local_storages_;
219 inline static std::atomic<xtd::uint64> next_id_;
228 template<
typename type_t>
231 template<
typename type_t>
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
virtual auto length() const noexcept -> size_type
Gets a size that represents the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:122
static auto join(const basic_string &separator, const collection_t &values) noexcept -> basic_string
Definition basic_string.hpp:1258
Represents a thread-safe, unordered collection of objects.
Definition concurrent_bag.hpp:37
auto is_synchronized() const noexcept -> bool override
Gets a value indicating whether access to the xtd::collections::concurrent::concurrent_bag <type_t> i...
Definition concurrent_bag.hpp:104
auto get_enumerator() const -> xtd::collections::generic::enumerator< value_type > override
Returns an enumerator that iterates through a collection.
Definition concurrent_bag.hpp:130
xtd::collections::generic::dictionary< xtd::intptr, xtd::ptr< collection_type > > storage_type
Represents the concurrent bag collection type.
Definition concurrent_bag.hpp:53
auto count() const noexcept -> xtd::usize override
Gets the number of elements contained in the xtd::collections::generic::icollection.
Definition concurrent_bag.hpp:79
auto add(const_reference item) -> void override
Adds an item to the xtd::collections::concurrent::concurrent_bag <type_t>.
Definition concurrent_bag.hpp:113
auto try_add(const_reference item) -> bool override
Attempts to add an object to the xtd::collections::concurrent::concurrent_bag <type_t>.
Definition concurrent_bag.hpp:156
auto is_empty() const noexcept -> bool
Gets a value indicating whether the xtd::collections::concurrent::concurrent_bag <type_t> is emtpy.
Definition concurrent_bag.hpp:83
auto to_string() const noexcept -> xtd::string override
Returns a xtd::string that represents the current object.
Definition concurrent_bag.hpp:150
auto is_read_only() const noexcept -> bool override
Gets a value indicating whether the xtd::collections::concurrent::concurrent_bag <type_t> is read-onl...
Definition concurrent_bag.hpp:88
typename iproducer_consumer_collection< type_t >::value_type value_type
Represents the concurrent bag value type.
Definition concurrent_bag.hpp:43
xtd::collections::generic::queue< value_type > collection_type
Represents the concurrent bag collection type.
Definition concurrent_bag.hpp:49
concurrent_bag(std::initializer_list< type_t > items)
Constructs the container with the contents of the specified initializer list, and allocator.
Definition concurrent_bag.hpp:63
const value_type & const_reference
Represents the const reference of list value type.
Definition concurrent_bag.hpp:47
concurrent_bag(const xtd::collections::generic::ienumerable< value_type > &collection)
Initializes a new instance of the xtd::collections::concurrent::concurrent_bag <type_t> class that co...
Definition concurrent_bag.hpp:68
collection_type * local_storage_type
Represents the concurrent bag collection type.
Definition concurrent_bag.hpp:51
concurrent_bag()=default
Initializes a new instance of the xtd::collections::concurrent::concurrent_bag <type_t> class.
auto to_array() const -> xtd::array< value_type > override
Copies the elements contained in the xtd::collections::concurrent::concurrent_bag <type_t> to a new a...
Definition concurrent_bag.hpp:139
auto try_peek(reference item) const -> bool
Attempts to return an object from the xtd::collections::concurrent::concurrent_bag <type_t> without r...
Definition concurrent_bag.hpp:165
auto copy_to(xtd::array< value_type > &array, xtd::usize array_index) const -> void override
Copies the elements of the xtd::collections::concurrent::concurrent_bag <type_t> to an xtd::array,...
Definition concurrent_bag.hpp:119
auto try_take(reference item) -> bool override
Attempts to remove and return an object from the xtd::collections::concurrent::concurrent <type_t>.
Definition concurrent_bag.hpp:178
value_type & reference
Represents the reference of list value type.
Definition concurrent_bag.hpp:45
Defines methods to manipulate thread-safe collections intended for producer/consumer usage....
Definition iproducer_consumer_collection.hpp:30
virtual auto sync_root() const noexcept -> const object &=0
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollecti...
virtual auto count() const noexcept -> xtd::usize=0
Gets the number of elements contained in the xtd::collections::generic::icollection.
virtual auto to_array() const -> xtd::array< type_t >=0
Copies the elements contained in the xtd::collections::concurrent::iproducer_consumer_collection <typ...
Represents a collection of keys and values.
Definition dictionary.hpp:63
virtual auto clear() -> void=0
Removes all items from the xtd::collections::generic::icollection <type_t>.
typename xtd::collections::generic::ienumerable< type_t >::value_type value_type
Represents the xtd::collections::generic::icollection value type.
Definition icollection.hpp:51
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:82
auto add_range(const xtd::collections::generic::ienumerable< type_t > &enumerable) -> void
Adds copy of elements from the specified collection to the end of the xtd::collections::generic::list...
Definition list.hpp:302
Represents a first-in, first-out collection of objects.
Definition queue.hpp:47
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
static auto decrement(int32 &location) noexcept -> int32
Decrements a specified variable and stores the result, as an atomic operation.
static auto increment(int32 &location) noexcept -> int32
Increments a specified variable and stores the result, as an atomic operation.
static auto current_thread() noexcept -> thread &
Gets the currently running thread.
Contains xtd::collections::generic::dictionary <key_t, value_t> class.
Contains xtd::collections::generic::queue <value_t> class.
generic::enumerator< xtd::any_object > enumerator
Supports a simple iteration over a non-generic collection.
Definition enumerator.hpp:28
@ not_supported
The method or operation is not supported.
Definition exception_case.hpp:77
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
#define lock_guard_(object)
The lock_guard_ keyword marks a statement block_guard as a critical section by obtaining the mutual-e...
Definition lock_guard.hpp:65
std::int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
auto as(any_object &o) -> type_t
Casts a type into another type.
Definition __as_any_object.hpp:60
auto new_ptr(args_t &&... args) -> xtd::ptr< type_t >
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ i
The I key.
Definition console_key.hpp:104
Contains xtd::threading::interlocked class.
Contains xtd::collections::concurrent::iproducer_consumer_collection <type_t> interface.
Contains lock_guard_ keyword.
Provides several thread-safe collection classes that should be used in place of the corresponding typ...
Definition concurrent_bag.hpp:20
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
const type_t & const_reference
Represents the read_only_span const reference type.
Definition read_only_span.hpp:68
Contains xtd::new_ptr method.