~haggai-eran/nux/rtl-rebased

« back to all changes in this revision

Viewing changes to NuxCore/ThreadGNU.cpp

  • Committer: Jay Taoko
  • Date: 2011-10-21 23:49:15 UTC
  • mfrom: (508.1.2 nux-20)
  • Revision ID: jay.taoko@canonical.com-20111021234915-hnzakb5ndebica8i
* Removed custom Nux types: t_u32, t_s32, t_bool, ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
namespace nux
27
27
{
28
28
 
29
 
  t_int NThreadSafeCounter::Increment()
 
29
  int NThreadSafeCounter::Increment()
30
30
  {
31
31
    return __sync_add_and_fetch (&m_Counter, 1);
32
32
  }
33
33
 
34
 
  t_int NThreadSafeCounter::Decrement()
 
34
  int NThreadSafeCounter::Decrement()
35
35
  {
36
36
    return __sync_add_and_fetch (&m_Counter, -1);
37
37
  }
38
38
 
39
 
  t_int NThreadSafeCounter::Set (t_int i)
 
39
  int NThreadSafeCounter::Set (int i)
40
40
  {
41
41
    return __sync_lock_test_and_set (&m_Counter, i);
42
42
  }
43
43
 
44
 
  t_int NThreadSafeCounter::GetValue() const
 
44
  int NThreadSafeCounter::GetValue() const
45
45
  {
46
46
    return m_Counter;
47
47
  }
48
48
 
49
 
  t_int NThreadSafeCounter::operator ++ ()
 
49
  int NThreadSafeCounter::operator ++ ()
50
50
  {
51
51
    return Increment();
52
52
  }
53
53
 
54
 
  t_int NThreadSafeCounter::operator -- ()
 
54
  int NThreadSafeCounter::operator -- ()
55
55
  {
56
56
    return Decrement();
57
57
  }
58
58
 
59
 
  t_bool NThreadSafeCounter::operator == (t_int i)
 
59
  bool NThreadSafeCounter::operator == (int i)
60
60
  {
61
61
    return (m_Counter == i);
62
62
  }
65
65
  BOOL NThreadLocalStorage::m_TLSUsed[NThreadLocalStorage::NbTLS];
66
66
  NThreadLocalStorage::TLS_ShutdownCallback  NThreadLocalStorage::m_TLSCallbacks[NThreadLocalStorage::NbTLS];
67
67
 
68
 
  BOOL NThreadLocalStorage::RegisterTLS(t_u32 index, NThreadLocalStorage::TLS_ShutdownCallback shutdownCallback)
 
68
  BOOL NThreadLocalStorage::RegisterTLS(unsigned int index, NThreadLocalStorage::TLS_ShutdownCallback shutdownCallback)
69
69
  {
70
70
    NUX_RETURN_VALUE_IF_FALSE(index < NThreadLocalStorage::NbTLS, FALSE);
71
71
    NUX_RETURN_VALUE_IF_TRUE(m_TLSUsed[index], TRUE); // already registered
75
75
    return TRUE;
76
76
  }
77
77
 
78
 
  BOOL NThreadLocalStorage::UnRegisterTLS (t_u32 index)
 
78
  BOOL NThreadLocalStorage::UnRegisterTLS (unsigned int index)
79
79
  {
80
80
    NUX_RETURN_VALUE_IF_FALSE(index < NThreadLocalStorage::NbTLS, FALSE);
81
81
    NUX_RETURN_VALUE_IF_FALSE(m_TLSUsed[index], FALSE);
91
91
  {
92
92
    Memset (m_TLSUsed, 0, sizeof (m_TLSUsed) );
93
93
 
94
 
    for (t_u32 i = 0; i < NThreadLocalStorage::NbTLS; i++)
 
94
    for (unsigned int i = 0; i < NThreadLocalStorage::NbTLS; i++)
95
95
    {
96
96
      // Fill the array with invalid values
97
97
      m_TLSIndex[i] = 0;
111
111
  {
112
112
    TLS_ShutdownCallback *callback = m_TLSCallbacks;
113
113
 
114
 
    for (t_u32 i = 0; i < NThreadLocalStorage::NbTLS; ++i, ++callback)
 
114
    for (unsigned int i = 0; i < NThreadLocalStorage::NbTLS; ++i, ++callback)
115
115
    {
116
116
      if (*callback)
117
117
      {
218
218
    return 0;
219
219
  }
220
220
 
221
 
  t_u32 NThread::GetExitCode() const
 
221
  unsigned int NThread::GetExitCode() const
222
222
  {
223
223
    return m_ThreadCtx.m_dwExitCode;
224
224
  }
225
225
 
226
 
  t_u32 NThread::GetThreadId()
 
226
  unsigned int NThread::GetThreadId()
227
227
  {
228
 
    return (t_u32) m_ThreadCtx.m_dwTID;
 
228
    return (unsigned int) m_ThreadCtx.m_dwTID;
229
229
  }
230
230
 
231
231
  ThreadState NThread::GetThreadState() const