A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
core
model
system-thread.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage.inria.fr>
19
*/
20
21
#ifndef SYSTEM_THREAD_H
22
#define SYSTEM_THREAD_H
23
24
#include "ns3/core-config.h"
25
#include "
callback.h
"
26
#ifdef HAVE_PTHREAD_H
27
#include <pthread.h>
28
#endif
/* HAVE_PTHREAD_H */
29
36
namespace
ns3
{
37
56
class
SystemThread
:
public
SimpleRefCount
<SystemThread>
57
{
58
public
:
59
60
#ifdef HAVE_PTHREAD_H
61
62
typedef
pthread_t
ThreadId
;
63
#endif
64
126
SystemThread
(
Callback<void>
callback);
127
132
~SystemThread
();
133
137
void
Start
(
void
);
138
143
void
Join
(
void
);
149
static
ThreadId
Self
(
void
);
150
157
static
bool
Equals
(
ThreadId
id
);
158
159
private
:
160
#ifdef HAVE_PTHREAD_H
161
167
static
void
*
DoRun
(
void
*arg);
168
169
Callback<void>
m_callback
;
170
pthread_t
m_thread
;
171
#endif
172
};
173
174
}
// namespace ns3
175
176
#endif
/* SYSTEM_THREAD_H */
177
178
ns3::Callback< void >
ns3::SystemThread::Start
void Start(void)
Start a thread of execution, running the provided callback.
Definition:
system-thread.cc:50
ns3::SystemThread::Self
static ThreadId Self(void)
Returns the current thread Id.
Definition:
system-thread.cc:89
ns3::SystemThread::~SystemThread
~SystemThread()
Destroy a SystemThread object.
Definition:
system-thread.cc:44
ns3::SystemThread::m_thread
pthread_t m_thread
The thread id of the child thread.
Definition:
system-thread.h:170
ns3::SystemThread
A class which provides a relatively platform-independent thread primitive.
Definition:
system-thread.h:56
ns3::SystemThread::SystemThread
SystemThread(Callback< void > callback)
Create a SystemThread object.
Definition:
system-thread.cc:38
callback.h
Declaration of the various callback functions.
ns3::SystemThread::ThreadId
pthread_t ThreadId
Type alias for the system-dependent thread object.
Definition:
system-thread.h:62
ns3::SystemThread::DoRun
static void * DoRun(void *arg)
Invoke the callback in the new thread.
Definition:
system-thread.cc:79
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SystemThread::Equals
static bool Equals(ThreadId id)
Compares an ThreadId with the current ThreadId .
Definition:
system-thread.cc:96
ns3::SystemThread::Join
void Join(void)
Suspend the caller until the thread of execution, running the provided callback, finishes.
Definition:
system-thread.cc:65
ns3::SystemThread::m_callback
Callback< void > m_callback
The main function for this thread when launched.
Definition:
system-thread.h:169
ns3::SimpleRefCount
A template-based reference counting class.
Definition:
simple-ref-count.h:73
Generated on Wed Nov 7 2018 10:01:50 for ns-3 by
1.8.14