Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ConcurrencyGlobal.cc
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/* ConcurrencyGlobal.h (C) 2000-2026 */
9/* */
10/* Global definitions for the 'Concurrency' component of '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/IThreadImplementationService.h"
25#include "arccore/concurrency/Task.h"
26
27#include "arccore/concurrency/NullThreadImplementation.h"
28#include "arccore/concurrency/SpinLock.h"
29
30#ifdef ARCCORE_HAS_GLIB
31#include "arccore/concurrency/GlibThreadImplementation.h"
32#endif
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37namespace Arcane
38{
39
40namespace
41{
42 NullThreadImplementation global_null_thread_implementation;
43 ReferenceCounter<IThreadImplementation> global_thread_implementation{ &global_null_thread_implementation };
44} // namespace
45
46/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
48
49IThreadImplementation* Concurrency::
50getThreadImplementation()
51{
52 return global_thread_implementation.get();
53}
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
58IThreadImplementation* Concurrency::
59setThreadImplementation(IThreadImplementation* service)
60{
61 IThreadImplementation* old_service = global_thread_implementation.get();
62 global_thread_implementation = service;
63 if (!service)
64 global_thread_implementation = &global_null_thread_implementation;
65 return old_service;
66}
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
72createGlibThreadImplementation()
73{
74#ifdef ARCCORE_HAS_GLIB
76#else
77 throw NotSupportedException(A_FUNCINFO, "GLib is not available Recompile Arccore with ARCCORE_ENABLE_GLIB=TRUE");
78#endif
79}
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
83
85{
86 public:
87
88 static Ref<IThreadImplementation> create()
89 {
91 }
92};
93
95createNullThreadImplementation()
96{
97 return NullThreadImplementationFactory::create();
98}
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102
103void IThreadImplementation::
104_deprecatedCreateSpinLock(Int64* spin_lock_addr)
105{
106 createSpinLock(spin_lock_addr);
107}
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112void IThreadImplementation::
113_deprecatedLockSpinLock(Int64* spin_lock_addr, Int64* scoped_spin_lock_addr)
114{
115 lockSpinLock(spin_lock_addr, scoped_spin_lock_addr);
116}
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121void IThreadImplementation::
122_deprecatedUnlockSpinLock(Int64* spin_lock_addr, Int64* scoped_spin_lock_addr)
123{
124 unlockSpinLock(spin_lock_addr, scoped_spin_lock_addr);
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
134
135/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137
138} // namespace Arcane
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143namespace Arccore
144{
146}
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
#define ARCCORE_DEFINE_REFERENCE_COUNTED_CLASS(class_name)
Macro to define methods and types for a class that uses a reference counter.
Management of references to a C++ class.
static Int32 maxAllowedThread()
Maximum number of allowed threads for multi-threading.
Implementation of ITreadImplementation with 'Glib'.
Int32 nbAllowedThread() const
Maximum number of threads used to manage tasks.
Implementation of threads in single-threaded mode.
Reference to an instance.
Encapsulation of a pointer with a reference counter.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.
Namespace of Arccore.