Arcane  v3.16.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
15#include "arccore/base/ReferenceCounter.h"
16#include "arccore/base/Ref.h"
17#include "arccore/base/NotSupportedException.h"
18
19#include "arccore/concurrency/ConcurrencyGlobal.h"
20
21#include "arccore/concurrency/NullThreadImplementation.h"
22#include "arccore/concurrency/SpinLock.h"
23
24#ifdef ARCCORE_HAS_GLIB
25#include "arccore/concurrency/GlibThreadImplementation.h"
26#endif
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane
32{
33
34namespace
35{
36 NullThreadImplementation global_null_thread_implementation;
37 ReferenceCounter<IThreadImplementation> global_thread_implementation{ &global_null_thread_implementation };
38} // namespace
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43IThreadImplementation* Concurrency::
44getThreadImplementation()
45{
46 return global_thread_implementation.get();
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
52IThreadImplementation* Concurrency::
53setThreadImplementation(IThreadImplementation* service)
54{
55 IThreadImplementation* old_service = global_thread_implementation.get();
56 global_thread_implementation = service;
57 if (!service)
58 global_thread_implementation = &global_null_thread_implementation;
59 return old_service;
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
66createGlibThreadImplementation()
67{
68#ifdef ARCCORE_HAS_GLIB
70#else
71 throw NotSupportedException(A_FUNCINFO, "GLib is not available Recompile Arccore with ARCCORE_ENABLE_GLIB=TRUE");
72#endif
73}
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
79{
80 public:
81
82 static Ref<IThreadImplementation> create()
83 {
85 }
86};
87
89createNullThreadImplementation()
90{
91 return NullThreadImplementationFactory::create();
92}
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97void IThreadImplementation::
98_deprecatedCreateSpinLock(Int64* spin_lock_addr)
99{
100 createSpinLock(spin_lock_addr);
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106void IThreadImplementation::
107_deprecatedLockSpinLock(Int64* spin_lock_addr, Int64* scoped_spin_lock_addr)
108{
109 lockSpinLock(spin_lock_addr, scoped_spin_lock_addr);
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115void IThreadImplementation::
116_deprecatedUnlockSpinLock(Int64* spin_lock_addr, Int64* scoped_spin_lock_addr)
117{
118 unlockSpinLock(spin_lock_addr, scoped_spin_lock_addr);
119}
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124} // namespace Arcane
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129namespace Arccore
130{
131ARCCORE_DEFINE_REFERENCE_COUNTED_CLASS(Arcane::IThreadImplementation);
132}
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
#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++.
Implémentation de ITreadImplementation avec la 'Glib'.
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.
Espace de nom de Arccore.