Arcane
4.1.12.0
User documentation
Loading...
Searching...
No Matches
ThreadPrivate.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
/* ThreadPrivate.cc (C) 2000-2025 */
9
/* */
10
/* Class allowing the storage of a specific value per thread. */
11
/*---------------------------------------------------------------------------*/
12
/*---------------------------------------------------------------------------*/
13
14
#include "arccore/concurrency/ThreadPrivate.h"
15
16
/*---------------------------------------------------------------------------*/
17
/*---------------------------------------------------------------------------*/
18
19
namespace
Arcane
20
{
21
22
/*---------------------------------------------------------------------------*/
23
/*---------------------------------------------------------------------------*/
24
25
ThreadPrivateStorage::
26
ThreadPrivateStorage()
27
: m_storage(nullptr)
28
{
29
}
30
31
ThreadPrivateStorage::
32
~ThreadPrivateStorage()
33
{
34
}
35
36
void
ThreadPrivateStorage::
37
initialize()
38
{
39
if
(!m_storage) {
40
m_storage =
new
GlibPrivate
();
41
m_storage->create();
42
}
43
}
44
45
void
* ThreadPrivateStorage::
46
getValue()
47
{
48
return
m_storage->getValue();
49
}
50
51
void
ThreadPrivateStorage::
52
setValue(
void
* v)
53
{
54
m_storage->setValue(v);
55
}
56
57
/*---------------------------------------------------------------------------*/
58
/*---------------------------------------------------------------------------*/
59
60
void
* ThreadPrivateBase::
61
item()
62
{
63
void
* ptr = m_key->getValue();
64
if
(ptr) {
65
return
ptr;
66
}
67
void
* new_ptr =
nullptr
;
68
{
69
GlibMutex::Lock
x(m_mutex);
70
new_ptr = m_create_functor->createInstance();
71
}
72
m_key->setValue(new_ptr);
73
return
new_ptr;
74
}
75
76
/*---------------------------------------------------------------------------*/
77
/*---------------------------------------------------------------------------*/
78
79
}
// namespace Arcane
80
81
/*---------------------------------------------------------------------------*/
82
/*---------------------------------------------------------------------------*/
Arcane::GlibMutex::Lock
Definition
GlibAdapter.h:45
Arcane::GlibPrivate
Definition
GlibAdapter.h:82
Arcane
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition
AbstractCaseDocumentVisitor.cc:21
arccore
concurrency
ThreadPrivate.cc
Generated on
for Arcane by
1.16.1