src/core/model/unix-system-thread.cc
author Josh Pelkey <jpelkey@gatech.edu>
Fri, 13 May 2011 14:52:27 -0400
changeset 7169 358f71a624d8
parent 6821 203367ae7433
child 7256 b04ba6772f8c
permissions -rw-r--r--
core coding style changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * Copyright (c) 2008 INRIA
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 *
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 *
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 *
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
 *
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage.inria.fr>
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
 */
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
#include <pthread.h>
3488
517acaf61a69 bug 262: fix g++ 4.3 build
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 3425
diff changeset
    22
#include <string.h>
3790
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    23
#include <signal.h>
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include "fatal-error.h"
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
#include "system-thread.h"
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
#include "log.h"
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
NS_LOG_COMPONENT_DEFINE ("SystemThread");
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
namespace ns3 {
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
//
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
// Private implementation class for the SystemThread class.  The deal is
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
// that we export the SystemThread class to the user.  The header just 
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
// declares a class and its members.  There is a forward declaration for
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
// a private implementation class there and a member declaration.  Thus
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
// there is no knowledge of the implementation in the exported header.
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
//
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
// We provide an implementation class for each operating system.  This is
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
// the Unix implementation of the SystemThread.
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
//
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
// In order to use the SystemThread, you will include "system-thread.h" and
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
// get the implementation by linking unix-system-thread.cc (if you are running
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
// a Posix system).
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
//
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
class SystemThreadImpl
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
public:
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
  SystemThreadImpl (Callback<void> callback);
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
  void Start (void);
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
  void Join (void);
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
    53
  void Shutdown (void);
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
    54
  bool Break (void);
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
private:
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
  static void *DoRun (void *arg);
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
  Callback<void> m_callback;
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
  pthread_t m_thread;
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
    60
  bool m_break;
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
  void *    m_ret;
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
};
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
SystemThreadImpl::SystemThreadImpl (Callback<void> callback)
6118
fdf5d6cb1dba Initialize all members in SystemThread c-tor
Pavel Boyko <boyko@iitp.ru>
parents: 5505
diff changeset
    65
  : m_callback (callback), m_break (false)
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
  NS_LOG_FUNCTION_NOARGS ();
3790
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    68
  // Make sure we have a SIGALRM handler which does not terminate
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    69
  // our process.
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    70
  struct sigaction act;
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    71
  act.sa_flags = 0;
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    72
  sigemptyset (&act.sa_mask);
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    73
  act.sa_handler = SIG_IGN;
2c655e67f7b1 Apply thread interrupt patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3488
diff changeset
    74
  sigaction (SIGALRM, &act, 0);
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
}
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
    77
void
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
SystemThreadImpl::Start (void)
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
  NS_LOG_FUNCTION_NOARGS ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
  int rc = pthread_create (&m_thread, NULL, &SystemThreadImpl::DoRun,
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
    83
                           (void *)this);
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
  if (rc) 
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
    {
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
      NS_FATAL_ERROR ("pthread_create failed: " << rc << "=\"" << 
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
    88
                      strerror(rc) << "\".");
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
    }
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
}
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
    92
void
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
SystemThreadImpl::Join (void)
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
  NS_LOG_FUNCTION_NOARGS ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
  void *thread_return;
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
  int rc = pthread_join (m_thread, &thread_return);
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
  if (rc) 
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
    {
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
      NS_FATAL_ERROR ("pthread_join failed: " << rc << "=\"" << 
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   102
                      strerror(rc) << "\".");
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
    }
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
}
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   106
void
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   107
SystemThreadImpl::Shutdown (void)
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   108
{
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   109
  NS_LOG_FUNCTION_NOARGS ();
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   110
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   111
  m_break = true;
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   112
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   113
  // send a SIGALRM signal on the target thread to make sure that it
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   114
  // will unblock.
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   115
  pthread_kill (m_thread, SIGALRM);
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   116
}
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   117
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   118
bool
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   119
SystemThreadImpl::Break (void)
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   120
{
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   121
  NS_LOG_FUNCTION_NOARGS ();
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   122
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   123
  return m_break;
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   124
}
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   125
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   126
void *
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
SystemThreadImpl::DoRun (void *arg)
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
  NS_LOG_FUNCTION_NOARGS ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
  SystemThreadImpl *self = static_cast<SystemThreadImpl *> (arg);
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
  self->m_callback ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
  return 0;
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
}
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   136
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
//
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   138
// Remember that we just export the delcaration of the SystemThread class to
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   139
// the user.  There is no code to implement the SystemThread methods.  We
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
// have to do that here.  We just vector the calls to our implementation 
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
// class above.
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
//
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
SystemThread::SystemThread (Callback<void> callback) 
6118
fdf5d6cb1dba Initialize all members in SystemThread c-tor
Pavel Boyko <boyko@iitp.ru>
parents: 5505
diff changeset
   144
  : m_impl (new SystemThreadImpl (callback)), m_break (false)
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
  NS_LOG_FUNCTION_NOARGS ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   147
}
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   148
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
SystemThread::~SystemThread() 
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   150
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
  NS_LOG_FUNCTION_NOARGS ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
  delete m_impl;
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
}
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   154
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   155
void
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
SystemThread::Start (void)
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
  NS_LOG_FUNCTION_NOARGS ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   159
  m_impl->Start ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   160
}
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   161
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   162
void
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
SystemThread::Join (void) 
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
{
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
  NS_LOG_FUNCTION_NOARGS ();
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
  m_impl->Join ();
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   167
}
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   168
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   169
void
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   170
SystemThread::Shutdown (void) 
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   171
{
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   172
  NS_LOG_FUNCTION_NOARGS ();
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   173
  m_impl->Shutdown ();
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   174
}
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   175
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   176
bool
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   177
SystemThread::Break (void) 
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   178
{
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   179
  NS_LOG_FUNCTION_NOARGS ();
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   180
  return m_impl->Break ();
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6821
diff changeset
   181
}
3791
cf62138bd445 structured thread exit methods
Craig Dowell <craigdo@ee.washington.edu>
parents: 3790
diff changeset
   182
3425
c69779f5e51e add system threads and synchronization primitives
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   183
} // namespace ns3