Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
RequestListBase.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* RequestListBase.h (C) 2000-2025 */
9/* */
10/* Base class of a request list. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_MESSAGEPASSING_REQUESTLISTBASE_H
13#define ARCCORE_MESSAGEPASSING_REQUESTLISTBASE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/message_passing/IRequestList.h"
18#include "arccore/message_passing/Request.h"
19#include "arccore/collections/Array.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::MessagePassing::internal
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
34class ARCCORE_MESSAGEPASSING_EXPORT RequestListBase
35: public IRequestList
36{
37 public:
38
39 RequestListBase() = default;
40
41 public:
42
43 void add(Request r) override { _add(r); }
44 void add(Span<Request> r) override { _add(r); }
45 Int32 wait(eWaitType wait_type) final;
46 Int32 size() const override { return m_requests.size(); }
47 void clear() final;
48 void removeDoneRequests() override;
49 bool isRequestDone(Int32 index) const override { return m_requests_done[index]; }
50 Request request(Int32 index) const override { return m_requests[index]; }
51 ConstArrayView<Int32> doneRequestIndexes() const final;
52
53 protected:
54
55 virtual void _add(const Request& r)
56 {
57 m_requests.add(r);
58 m_requests_done.add(false);
59 }
60 virtual void _add(Span<Request> rlist)
61 {
62 m_requests.addRange(rlist);
63 m_requests_done.addRange(false, rlist.size());
64 }
65 virtual void _removeRequestAtIndex(Integer pos)
66 {
67 m_requests.remove(pos);
68 m_requests_done.remove(pos);
69 }
77 virtual void _wait(eWaitType wait_type) = 0;
78
79 protected:
80
81 ArrayView<Request> _requests() { return m_requests; }
82 ArrayView<bool> _requestsDone() { return m_requests_done; }
83
84 private:
85
86 UniqueArray<Request> m_requests;
87 UniqueArray<bool> m_requests_done;
88 UniqueArray<Int32> m_done_request_indexes;
89};
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94} // namespace Arcane::MessagePassing::internal
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99namespace Arccore::MessagePassing::internal
100{
102}
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107#endif
Modifiable view of an array of type T.
Constant view of an array of type T.
bool isRequestDone(Int32 index) const override
Indicates if the request is finished since the last call to wait().
void add(Request r) override
Adds the request r to the list of requests.
Request request(Int32 index) const override
The index-th request in the list.
virtual void _wait(eWaitType wait_type)=0
Performs the wait or test.
Int32 size() const override
Number of requests.
void add(Span< Request > r) override
Adds the list of requests rlist to the list of requests.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
Definition Span.h:327
View of an array of elements of type T.
Definition Span.h:635
1D data vector with value semantics (STL style).
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.