ANNA Suite  2020b
Multipurpose development suite for Telco applications
Public Member Functions | List of all members
anna::ThreadData< T > Class Template Reference

#include <ThreadData.hpp>

Public Member Functions

 ThreadData (const char *name)
 
T & get ()
 

Detailed Description

template<typename T>
class anna::ThreadData< T >

Template que facilita la creacion de datos dependientes del Thread.

See also
anna::Thread
Parameters
TClase asociada a este repositorio, debe tener un constructor vacio.

Constructor & Destructor Documentation

◆ ThreadData()

template<typename T >
anna::ThreadData< T >::ThreadData ( const char *  name)
inline

Contructor.

Parameters
nameNombre logico de esta template.
33 : a_name(name) {;}

Member Function Documentation

◆ get()

template<typename T >
T& anna::ThreadData< T >::get ( )
inline

Devuelve los datos asociados al thread desde el que se invoca a este metodo. Si no existen se crean mediante el contructor vacio.

Returns
Los datos asociados al thread desde el que se invoca a este metodo.
40  {
41 #ifndef _MT
42  return a_data;
43 #else
44  Guard guard(a_mutex, "anna::ThreadData");
45  const int index = (int) functions::getCurrentThread();
46  data_iterator ii = a_datas.find(index);
47  T* result = NULL;
48 
49  if(ii == a_datas.end()) {
50  result = new T;
51  a_datas.insert(value_type(index, result));
52  } else
53  result = ii->second;
54 
55  LOGDEBUG(
56  std::string msg("anna::ThreadData { Name: ");
57  msg += a_name;
58  msg += " | ";
60  msg += " }";
62  );
63  return *result;
64 #endif
65  }
#define anna_ptrnumber_cast(pointer)
Definition: defines.hpp:118
static void debug(const std::string &text, const char *fromFile, const int fromLine)
Definition: Logger.hpp:305
#define LOGDEBUG(a)
Definition: defines.hpp:64
static std::string asHexString(const int number)
static pthread_t getCurrentThread()
#define ANNA_FILE_LOCATION
Definition: defines.hpp:23
Here is the call graph for this function:

The documentation for this class was generated from the following file: