Arcane
v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ThreadPrivate.cc
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
//-----------------------------------------------------------------------------
3
// Copyright 2000-2022 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-2018 */
9
/* */
10
/* Classe permettant de conserver une valeur spécifique par thread. */
11
/*---------------------------------------------------------------------------*/
12
/*---------------------------------------------------------------------------*/
13
14
#include "arccore/concurrency/ThreadPrivate.h"
15
16
/*---------------------------------------------------------------------------*/
17
/*---------------------------------------------------------------------------*/
18
19
namespace
Arccore
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
52
void
ThreadPrivateStorage::
53
setValue(
void
* v)
54
{
55
m_storage->setValue(v);
56
}
57
58
/*---------------------------------------------------------------------------*/
59
/*---------------------------------------------------------------------------*/
60
61
void
* ThreadPrivateBase::
62
item()
63
{
64
void
* ptr = m_key->getValue();
65
if
(ptr){
66
return
ptr;
67
}
68
void
* new_ptr =
nullptr
;
69
{
70
GlibMutex::Lock
x(m_mutex);
71
new_ptr = m_create_functor->createInstance();
72
}
73
m_key->setValue(new_ptr);
74
return
new_ptr;
75
}
76
77
/*---------------------------------------------------------------------------*/
78
/*---------------------------------------------------------------------------*/
79
80
}
// End namespace Arccore
81
82
/*---------------------------------------------------------------------------*/
83
/*---------------------------------------------------------------------------*/
Arccore::GlibMutex::Lock
Definition
GlibAdapter.h:40
Arccore::GlibPrivate
Definition
GlibAdapter.h:67
Arccore
Espace de nom de Arccore.
Definition
ArcaneTypes.h:24
arccore
concurrency
ThreadPrivate.cc
Généré le Lundi 18 Novembre 2024 02:56:57 pour Arcane par
1.9.8