View | Details | Raw Unified | Return to bug 1764
Collapse All | Expand All

(-)a/src/core/model/system-mutex.h (-1 / +34 lines)
 Lines 22-27    Link Here 
22
#define SYSTEM_MUTEX_H
22
#define SYSTEM_MUTEX_H
23
23
24
#include "ptr.h"
24
#include "ptr.h"
25
#include "ns3/core-config.h"
25
26
26
/**
27
/**
27
 * @file
28
 * @file
 Lines 58-63    Link Here 
58
class SystemMutex 
59
class SystemMutex 
59
{
60
{
60
public:
61
public:
62
63
#ifndef HAVE_PTHREAD_H
64
  // This minimal implementation is needed for to support compilation
65
  // of the thread-safe Schedule implementation, on systems without
66
  // thread support.
67
  
68
  /** Constructor */
69
  SystemMutex () { };
70
  /** Destructor */
71
  ~SystemMutex () { };
72
73
#else
61
  SystemMutex ();
74
  SystemMutex ();
62
  ~SystemMutex ();
75
  ~SystemMutex ();
63
76
 Lines 74-79    Link Here 
74
private:
87
private:
75
  /** The (system-dependent) implementation. */
88
  /** The (system-dependent) implementation. */
76
  SystemMutexPrivate * m_priv;
89
  SystemMutexPrivate * m_priv;
90
91
#endif /* HAVE_PTHREAD_H */
77
};
92
};
78
93
79
/**
94
/**
 Lines 118-123    Link Here 
118
class CriticalSection
133
class CriticalSection
119
{
134
{
120
public:
135
public:
136
137
#ifndef HAVE_PTHREAD_H
138
  // This minimal implementation is needed for to support compilation
139
  // of the thread-safe Schedule implementation, on systems without
140
  // thread support.
141
142
  /**
143
   * Constructor
144
   * @param [in] mutex The mutex.
145
   */
146
  CriticalSection (SystemMutex &mutex) { };
147
  /** Destructor */
148
  ~CriticalSection () { };
149
150
#else /* HAVE_PTHREAD_H */
121
  /**
151
  /**
122
   * Construct with the required SystemMutex.
152
   * Construct with the required SystemMutex.
123
   *
153
   *
 Lines 128-134    Link Here 
128
  ~CriticalSection ();
158
  ~CriticalSection ();
129
private:
159
private:
130
  SystemMutex &m_mutex;  /**< The mutex. */
160
  SystemMutex &m_mutex;  /**< The mutex. */
131
};
161
162
#endif /* HAVE_PTHREAD_H */
163
164
};  // class CriticalSection
132
165
133
} // namespace ns3
166
} // namespace ns3
134
167
(-)a/src/core/model/system-thread.h (-5 / +31 lines)
 Lines 57-66    Link Here 
57
{
57
{
58
public:
58
public:
59
59
60
#ifdef HAVE_PTHREAD_H
60
#ifndef HAVE_PTHREAD_H
61
  // This minimal implementation is needed for to support compilation
62
  // of the thread-safe Schedule implementation, on systems without
63
  // thread support.
64
65
  /**
66
   * Fallback type alias for thread objects
67
   * on systems without thread support.
68
   */
69
  typedef void * ThreadId;
70
71
  /**
72
   * @brief Returns the default thread Id on systems without thread support.
73
   *
74
   * @returns Default thread Id. 
75
   */
76
  static ThreadId Self(void) { return 0; };
77
78
  /**
79
   * @brief Compares ThreadIds on systems without thread support.
80
   *
81
   * @param [in] id The ThreadId to compare to.
82
   * @returns @c true if @c id matches the current ThreadId.
83
   */
84
  static bool Equals(ThreadId id) { return true; };
85
  
86
#else /* HAVE_PTHREAD_H */
61
  /** Type alias for the system-dependent thread object. */
87
  /** Type alias for the system-dependent thread object. */
62
  typedef pthread_t ThreadId;
88
  typedef pthread_t ThreadId;
63
#endif
64
89
65
  /**
90
  /**
66
   * @brief Create a SystemThread object.
91
   * @brief Create a SystemThread object.
 Lines 157-163    Link Here 
157
  static bool Equals(ThreadId id);
182
  static bool Equals(ThreadId id);
158
183
159
private:
184
private:
160
#ifdef HAVE_PTHREAD_H
185
161
  /**
186
  /**
162
   * Invoke the callback in the new thread.
187
   * Invoke the callback in the new thread.
163
   *
188
   *
 Lines 168-175    Link Here 
168
193
169
  Callback<void> m_callback;  /**< The main function for this thread when launched. */
194
  Callback<void> m_callback;  /**< The main function for this thread when launched. */
170
  pthread_t m_thread;  /**< The thread id of the child thread. */
195
  pthread_t m_thread;  /**< The thread id of the child thread. */
171
#endif 
196
172
};
197
#endif /* HAVE_PTHREAD_H */
198
};  // class SystemThread
173
199
174
} // namespace ns3
200
} // namespace ns3
175
201
(-)a/src/core/model/unix-system-mutex.cc (+5 lines)
 Lines 106-111    Link Here 
106
    }
106
    }
107
}
107
}
108
108
109
#ifdef HAVE_PTHREAD_H
110
109
SystemMutex::SystemMutex() 
111
SystemMutex::SystemMutex() 
110
  : m_priv (new SystemMutexPrivate ())
112
  : m_priv (new SystemMutexPrivate ())
111
{
113
{
 Lines 145-148    Link Here 
145
  m_mutex.Unlock ();
147
  m_mutex.Unlock ();
146
}
148
}
147
149
150
#endif /* SYSTEM_MUTEX_H */
151
152
148
} // namespace ns3
153
} // namespace ns3
(-)a/src/core/wscript (-2 / +12 lines)
 Lines 236-241    Link Here 
236
        'model/watchdog.h',
236
        'model/watchdog.h',
237
        'model/synchronizer.h',
237
        'model/synchronizer.h',
238
        'model/make-event.h',
238
        'model/make-event.h',
239
        
240
        # Include always for compilation
241
        # of the thread-safe Schedule implementation,
242
        # even on systems without thread support.
243
        'model/system-mutex.h',
244
        'model/system-thread.h',
245
        
239
        'model/system-wall-clock-ms.h',
246
        'model/system-wall-clock-ms.h',
240
        'model/empty.h',
247
        'model/empty.h',
241
        'model/callback.h',
248
        'model/callback.h',
 Lines 350-357    Link Here 
350
        core_test.source.extend(['test/threaded-test-suite.cc'])
357
        core_test.source.extend(['test/threaded-test-suite.cc'])
351
        headers.source.extend([
358
        headers.source.extend([
352
                'model/unix-fd-reader.h',
359
                'model/unix-fd-reader.h',
353
                'model/system-mutex.h',
360
                # Include always for compilation
354
                'model/system-thread.h',
361
                # of the thread-safe Schedule implementation,
362
                # on systems without thread support.
363
                # 'model/system-mutex.h',
364
                # 'model/system-thread.h',
355
                'model/system-condition.h',
365
                'model/system-condition.h',
356
                ])
366
                ])
357
367

Return to bug 1764