Free Electron
Omega.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 /* This header simply has stuff that has to be after all the inter
8  dependendencies have been defined. */
9 
10 #ifndef __data_Omega_h__
11 #define __data_Omega_h__
12 
13 namespace fe
14 {
15 
16 template <typename R>
17 void Scope::assignIDNumber(const R &record)
18 {
19  SAFEGUARD_IF(m_locking);
20 
21 #if FE_SCOPE_GETRECORD
22  int *pID;
23  pID = m_paIDNumber->queryAttribute(record);
24  if(pID)
25  {
26  if(m_freeIDNumbers.size() != 0)
27  {
28  m_idNumbered[m_freeIDNumbers.back()] = record;
29  *pID = m_freeIDNumbers.back();
30 // feLog("re assignIDNumber %p %d\n",record.data(),*pID);
31  m_freeIDNumbers.pop_back();
32  }
33  else
34  {
35  int index = m_idNumbered.size();
36 // feLog("assignIDNumber %p %d\n",record.data(),index);
37  m_idNumbered.resize(index + 1);
38  *pID = index;
39  WeakRecord weak_record(record);
40  m_idNumbered[index] = weak_record;
41  }
42  }
43 #endif
44 
45  //* piggyback
46  std::atomic<int> *pSN;
47  pSN = m_paSerialNumber->queryAttribute(record);
48  if(pSN)
49  {
50  *pSN=m_serialCount++;
51 // feLog("assignIDNumber SN %p %d %s\n",record.data(),*pSN,
52 // record.layout()->name().c_str());
53  if(m_serialCount<0)
54  {
55  m_serialCount=0;
56  }
57  }
58 
59 pSN = m_paSerialNumber->queryAttribute(record);
60 }
61 
62 template <typename R>
63 void Scope::freeIDNumber(const R &r_old)
64 {
65  SAFEGUARD_IF(m_locking);
66 
67 #if FE_SCOPE_GETRECORD
68  int *pID;
69  if(m_paIDNumber &&
70  m_paIDNumber->queryAttribute(r_old, pID))
71  {
72 // feLog("freeIDNumber %p %d\n",stateblock,*pID);
73  m_freeIDNumbers.push_back(*pID);
74  m_idNumbered[*pID] = WeakRecord();
75  }
76 #endif
77 
78  //* piggyback
79  std::atomic<int> *pSN;
80  if(m_paSerialNumber &&
81  m_paSerialNumber->queryAttribute(r_old, pSN))
82  {
83 // feLog("freeIDNumber SN %p %d\n",stateblock,*pSN);
84  *pSN= -1;
85  }
86 }
87 
88 
89 
90 } /* namespace*/
91 
92 #endif /* __data_Omega_h__ */
93 
kernel
Definition: namespace.dox:3
bool queryAttribute(const RecordSB &r, T *&data)
Return true if the attribute exists in record.
Definition: Accessor.h:574