Skip to content

Commit eaf3b8a

Browse files
Merge pull request #1162 from arcaneframework/dev/gg-use-create-ref-in-several-parts
Use 'createRef()' instead of 'makeRef()' in some places.
2 parents c65441d + 44563d6 commit eaf3b8a

10 files changed

+61
-27
lines changed

arcane/src/arcane/core/ParallelMngDispatcher.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void ParallelMngDispatcherBuildInfo::
100100
_init()
101101
{
102102
if (!m_dispatchers){
103-
m_dispatchers_ref = makeRef(new MP::Dispatchers());
103+
m_dispatchers_ref = createRef<MP::Dispatchers>();
104104
m_dispatchers = m_dispatchers_ref.get();
105105
}
106106
if (!m_message_passing_mng){

arcane/src/arcane/core/ParallelMngDispatcher.h

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "arcane/core/IParallelMng.h"
1818
#include "arccore/base/ReferenceCounterImpl.h"
19+
#include "arccore/message_passing/MessagePassingMng.h"
1920

2021
#include <atomic>
2122

arcane/src/arcane/core/SerializedData.cc

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* SerializedData.cc (C) 2000-2022 */
8+
/* SerializedData.cc (C) 2000-2024 */
99
/* */
1010
/* Donnée sérialisée. */
1111
/*---------------------------------------------------------------------------*/
@@ -401,9 +401,8 @@ arcaneCreateSerializedDataRef(eDataType data_type, Int64 memory_size,
401401
Integer nb_dim, Int64 nb_element, Int64 nb_base_element,
402402
bool is_multi_size, Int64ConstArrayView dimensions, const ArrayShape& shape)
403403
{
404-
auto* x = new SerializedData(data_type, memory_size, nb_dim, nb_element,
405-
nb_base_element, is_multi_size, dimensions, shape);
406-
return makeRef(x);
404+
return createRef<SerializedData>(data_type, memory_size, nb_dim, nb_element,
405+
nb_base_element, is_multi_size, dimensions, shape);
407406
}
408407

409408
/*---------------------------------------------------------------------------*/
@@ -426,7 +425,7 @@ extern "C++" ARCANE_CORE_EXPORT
426425
Ref<ISerializedData>
427426
arcaneCreateEmptySerializedDataRef()
428427
{
429-
return makeRef(new SerializedData());
428+
return createRef<SerializedData>();
430429
}
431430

432431
/*---------------------------------------------------------------------------*/

arcane/src/arcane/parallel/mpi/MpiParallelMng.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ MpiParallelMngBuildInfo(MPI_Comm comm)
101101
::MPI_Comm_rank(comm,&comm_rank);
102102
::MPI_Comm_size(comm,&comm_nb_rank);
103103

104-
m_dispatchers_ref = makeRef<MP::Dispatchers>(new MP::Dispatchers());
104+
m_dispatchers_ref = createRef<MP::Dispatchers>();
105105
MP::Mpi::MpiMessagePassingMng::BuildInfo bi(comm_rank,comm_nb_rank,m_dispatchers_ref.get(),mpi_comm);
106106

107-
auto* mp = new MP::Mpi::MpiMessagePassingMng(bi);
108-
m_message_passing_mng_ref = makeRef<MP::MessagePassingMng>(mp);
107+
m_message_passing_mng_ref = createRef<MP::Mpi::MpiMessagePassingMng>(bi);
109108
}
110109

111110
/*---------------------------------------------------------------------------*/
@@ -309,7 +308,7 @@ class MpiParallelMngUtilsFactory
309308
else if (m_synchronizer_version == 5){
310309
if (do_print)
311310
tm->info() << "Using MpiSynchronizer V5";
312-
topology_info = makeRef<IVariableSynchronizerMpiCommunicator>(new VariableSynchronizerMpiCommunicator(mpi_pm));
311+
topology_info = createRef<VariableSynchronizerMpiCommunicator>(mpi_pm);
313312
#if defined(ARCANE_HAS_MPI_NEIGHBOR)
314313
generic_factory = arcaneCreateMpiNeighborVariableSynchronizerFactory(mpi_pm,topology_info);
315314
#else
@@ -323,9 +322,11 @@ class MpiParallelMngUtilsFactory
323322
}
324323
if (!generic_factory.get())
325324
ARCANE_FATAL("No factory created");
326-
return makeRef<IVariableSynchronizer>(new MpiVariableSynchronizer(pm,group,generic_factory,topology_info));
325+
return createRef<MpiVariableSynchronizer>(pm,group,generic_factory,topology_info);
327326
}
327+
328328
private:
329+
329330
Integer m_synchronizer_version = 1;
330331
Int32 m_synchronize_block_size = 32000;
331332
Int32 m_synchronize_nb_sequence = 1;
@@ -353,7 +354,7 @@ MpiParallelMng(const MpiParallelMngBuildInfo& bi)
353354
, m_is_communicator_owned(bi.is_mpi_comm_owned)
354355
, m_mpi_lock(bi.mpi_lock)
355356
, m_non_blocking_collective(nullptr)
356-
, m_utils_factory(makeRef<IParallelMngUtilsFactory>(new MpiParallelMngUtilsFactory()))
357+
, m_utils_factory(createRef<MpiParallelMngUtilsFactory>())
357358
{
358359
if (!m_world_parallel_mng){
359360
m_trace->debug()<<"[MpiParallelMng] No m_world_parallel_mng found, reverting to ourselves!";
@@ -872,8 +873,7 @@ class MpiParallelMng::RequestList
872873
Ref<IRequestList> MpiParallelMng::
873874
createRequestListRef()
874875
{
875-
IRequestList* x = new RequestList(this);
876-
return makeRef(x);
876+
return createRef<RequestList>(this);
877877
}
878878

879879
/*---------------------------------------------------------------------------*/

arcane/src/arcane/parallel/mpi/MpiParallelSuperMng.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* MpiParallelSuperMng.cc (C) 2000-2023 */
8+
/* MpiParallelSuperMng.cc (C) 2000-2024 */
99
/* */
1010
/* Gestionnaire de parallélisme utilisant MPI. */
1111
/*---------------------------------------------------------------------------*/
@@ -286,7 +286,7 @@ internalCreateWorldParallelMng(Int32 local_rank)
286286
bi.mpi_lock = nullptr;
287287

288288
tm->debug()<<"[MpiParallelSuperMng::internalCreateWorldParallelMng] pm->build()";
289-
Ref<IParallelMng> pm = makeRef<IParallelMng>(new MpiParallelMng(bi));
289+
Ref<IParallelMng> pm = createRef<MpiParallelMng>(bi);
290290
pm->build();
291291
return pm;
292292
}

arcane/src/arcane/parallel/mpithread/HybridParallelMng.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ HybridParallelMng(const HybridParallelMngBuildInfo& bi)
175175
, m_all_dispatchers(bi.all_dispatchers)
176176
, m_sub_builder_factory(bi.sub_builder_factory)
177177
, m_parent_container_ref(bi.container)
178-
, m_utils_factory(makeRef<IParallelMngUtilsFactory>(new ParallelMngUtilsFactoryBase()))
178+
, m_utils_factory(createRef<ParallelMngUtilsFactoryBase>())
179179
{
180180
if (!m_world_parallel_mng)
181181
m_world_parallel_mng = this;

arcane/src/arcane/parallel/thread/SharedMemoryParallelMng.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ SharedMemoryParallelMng(const SharedMemoryParallelMngBuildInfo& build_info)
113113
, m_sub_builder_factory(build_info.sub_builder_factory)
114114
, m_parent_container_ref(build_info.container)
115115
, m_mpi_communicator(build_info.communicator)
116-
, m_utils_factory(makeRef<IParallelMngUtilsFactory>(new ParallelMngUtilsFactoryBase()))
116+
, m_utils_factory(createRef<ParallelMngUtilsFactoryBase>())
117117
{
118118
if (!m_world_parallel_mng)
119119
m_world_parallel_mng = this;

arcane/src/arcane/utils/DependencyInjection.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* DependencyInjection.h (C) 2000-2021 */
8+
/* DependencyInjection.h (C) 2000-2024 */
99
/* */
1010
/* Types et fonctions pour gérer le pattern 'DependencyInjection'. */
1111
/*---------------------------------------------------------------------------*/
@@ -846,7 +846,7 @@ class InterfaceListRegisterer
846846
_registerFactory(FactoryInfo* fi)
847847
{
848848
auto* factory = new ConcreteFactory<InterfaceType, ConcreteType, ConstructorType>();
849-
fi->addFactory(makeRef<IInstanceFactory>(new InstanceFactory<InterfaceType>(fi, factory)));
849+
fi->addFactory(createRef<InstanceFactory<InterfaceType>>(fi, factory));
850850
// Applique récursivement pour les autres interfaces si nécessaire
851851
if constexpr (sizeof...(OtherInterfaces) > 0)
852852
_registerFactory<ConcreteType, ConstructorType, OtherInterfaces...>(fi);

arcane/src/arcane/utils/Ref.h

+35-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
1-
#include "arccore/base/Ref.h"
1+
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2+
//-----------------------------------------------------------------------------
3+
// Copyright 2000-2024 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+
/* Ref.h (C) 2000-2024 */
9+
/* */
10+
/* Gestion des références sur une instance. */
11+
/*---------------------------------------------------------------------------*/
12+
#ifndef ARCANE_UTILS_REF_H
13+
#define ARCANE_UTILS_REF_H
14+
/*---------------------------------------------------------------------------*/
15+
/*---------------------------------------------------------------------------*/
16+
17+
#include "arccore/base/Ref.h"
218
#include "arcane/utils/UtilsTypes.h"
19+
20+
/*---------------------------------------------------------------------------*/
21+
/*---------------------------------------------------------------------------*/
22+
323
namespace Arcane
424
{
25+
26+
/*---------------------------------------------------------------------------*/
27+
/*---------------------------------------------------------------------------*/
28+
529
using Arccore::makeRef;
630
using Arccore::makeRefFromInstance;
31+
using Arccore::createRef;
32+
33+
/*---------------------------------------------------------------------------*/
34+
/*---------------------------------------------------------------------------*/
35+
736
}
37+
38+
/*---------------------------------------------------------------------------*/
39+
/*---------------------------------------------------------------------------*/
40+
41+
#endif

arcane/src/arcane/utils/SHA1HashAlgorithm.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* SHA1HashAlgorithm.cc (C) 2000-2023 */
8+
/* SHA1HashAlgorithm.cc (C) 2000-2024 */
99
/* */
1010
/* Calcule de fonction de hashage SHA-1. */
1111
/*---------------------------------------------------------------------------*/
@@ -563,7 +563,7 @@ computeHash64(Span<const std::byte> input, ByteArray& output)
563563
Ref<IHashAlgorithmContext> SHA1HashAlgorithm::
564564
createContext()
565565
{
566-
return makeRef<IHashAlgorithmContext>(new SHA1Algorithm::SHA1());
566+
return createRef<SHA1Algorithm::SHA1>();
567567
}
568568

569569
/*---------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)