Arcane  v4.1.0.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ConcurrencyGlobal.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ConcurrencyGlobal.h (C) 2000-2025 */
9/* */
10/* Définitions globales de la composante 'Concurrency' de 'Arccore'. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/concurrency/ConcurrencyGlobal.h"
15
17#include "arccore/base/ReferenceCounter.h"
18#include "arccore/base/Ref.h"
19#include "arccore/base/NotSupportedException.h"
20
21#include "arccore/concurrency/ParallelFor.h"
22#include "arccore/concurrency/TaskFactory.h"
23#include "arccore/concurrency/ITaskImplementation.h"
24#include "arccore/concurrency/Task.h"
25
26#include "arccore/concurrency/NullThreadImplementation.h"
27#include "arccore/concurrency/SpinLock.h"
28
29#ifdef ARCCORE_HAS_GLIB
30#include "arccore/concurrency/GlibThreadImplementation.h"
31#endif
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36namespace Arcane
37{
38
39namespace
40{
41 NullThreadImplementation global_null_thread_implementation;
42 ReferenceCounter<IThreadImplementation> global_thread_implementation{ &global_null_thread_implementation };
43} // namespace
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48IThreadImplementation* Concurrency::
49getThreadImplementation()
50{
51 return global_thread_implementation.get();
52}
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
57IThreadImplementation* Concurrency::
58setThreadImplementation(IThreadImplementation* service)
59{
60 IThreadImplementation* old_service = global_thread_implementation.get();
61 global_thread_implementation = service;
62 if (!service)
63 global_thread_implementation = &global_null_thread_implementation;
64 return old_service;
65}
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
69
71createGlibThreadImplementation()
72{
73#ifdef ARCCORE_HAS_GLIB
75#else
76 throw NotSupportedException(A_FUNCINFO, "GLib is not available Recompile Arccore with ARCCORE_ENABLE_GLIB=TRUE");
77#endif
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
84{
85 public:
86
87 static Ref<IThreadImplementation> create()
88 {
90 }
91};
92
94createNullThreadImplementation()
95{
96 return NullThreadImplementationFactory::create();
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102void IThreadImplementation::
103_deprecatedCreateSpinLock(Int64* spin_lock_addr)
104{
105 createSpinLock(spin_lock_addr);
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111void IThreadImplementation::
112_deprecatedLockSpinLock(Int64* spin_lock_addr, Int64* scoped_spin_lock_addr)
113{
114 lockSpinLock(spin_lock_addr, scoped_spin_lock_addr);
115}
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119
120void IThreadImplementation::
121_deprecatedUnlockSpinLock(Int64* spin_lock_addr, Int64* scoped_spin_lock_addr)
122{
123 unlockSpinLock(spin_lock_addr, scoped_spin_lock_addr);
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136
137} // namespace Arcane
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142namespace Arccore
143{
145}
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
#define ARCCORE_DEFINE_REFERENCE_COUNTED_CLASS(class_name)
Macro pour définir les méthodes et types une classe qui utilise un compteur de référence.
Gestion des références à une classe C++.
static Int32 maxAllowedThread()
Nombre maximum de threads autorisés pour le multi-threading.
Implémentation de ITreadImplementation avec la 'Glib'.
Int32 nbAllowedThread() const
Nombre de threads utilisés au maximum pour gérer les tâches.
Interface d'un service implémentant le support des threads.
Implémentation des threads en mode mono-thread.
Référence à une instance.
Encapsulation d'un pointeur avec compteur de référence.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
std::int32_t Int32
Type entier signé sur 32 bits.
Espace de nom de Arccore.