ns-3 Direct Code Execution
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ns3::PthreadFiberManager Class Reference

#include <pthread-fiber-manager.h>

+ Inheritance diagram for ns3::PthreadFiberManager:
+ Collaboration diagram for ns3::PthreadFiberManager:

Public Member Functions

 PthreadFiberManager ()
virtual ~PthreadFiberManager ()
virtual struct FiberClone (struct Fiber *fiber)
virtual struct FiberCreate (void(*callback)(void *), void *context, uint32_t stackSize)
virtual struct FiberCreateFromCaller (void)
virtual void Delete (struct Fiber *fiber)
virtual uint32_t GetStackSize (struct Fiber *fiber) const
virtual void SetSwitchNotification (void(*fn)(void))
virtual void SwitchTo (struct Fiber *from, const struct Fiber *to)
- Public Member Functions inherited from ns3::FiberManager
virtual ~FiberManager ()

Private Member Functions

void RestoreFiber (struct PthreadFiber *fiber)
void Start (struct PthreadFiber *fiber)
void Wakeup (struct PthreadFiber *fiber)
void Yield (struct PthreadFiber *fiber)

Static Private Member Functions

static void * Run (void *arg)
static void * SelfStackBottom (void)

Private Attributes

void(* m_notifySwitch )(void)
StackTrampolinem_trampoline

Detailed Description

Definition at line 13 of file pthread-fiber-manager.h.

Constructor & Destructor Documentation

ns3::PthreadFiberManager::PthreadFiberManager ( )

Definition at line 240 of file pthread-fiber-manager.cc.

References m_trampoline.

ns3::PthreadFiberManager::~PthreadFiberManager ( )
virtual

Definition at line 246 of file pthread-fiber-manager.cc.

References m_trampoline.

Member Function Documentation

struct Fiber * ns3::PthreadFiberManager::Create ( void(*)(void *)  callback,
void *  context,
uint32_t  stackSize 
)
readvirtual
Parameters
callbackfunction to use as main loop for the newly-created fiber
stackSizesize of the stack to allocate for this fiber.
Returns
a newly-created fiber context.

Implements ns3::FiberManager.

Definition at line 417 of file pthread-fiber-manager.cc.

References ns3::PthreadFiberThread::context, CreateFromCaller(), ns3::PthreadFiberThread::func, ns3::SLEEP, ns3::PthreadFiberThread::stack_size, ns3::PthreadFiber::state, ns3::PthreadFiber::thread, and ns3::PthreadFiberThread::thread_started.

+ Here is the call graph for this function:

struct Fiber * ns3::PthreadFiberManager::CreateFromCaller ( void  )
readvirtual
Returns
an empty context

Create a fiber context which can be used as a from argument to the SwitchTo method This method is usually used to create a context which references the main 'normal' thread. i.e., the thread initially managed by the underlying kernel which runs on the kernel-managed stack.

Implements ns3::FiberManager.

Definition at line 430 of file pthread-fiber-manager.cc.

References ns3::PthreadFiberThread::condvar, ns3::PthreadFiberThread::func, m_trampoline, ns3::PthreadFiberThread::mutex, ns3::PthreadFiberThread::previous, ns3::PthreadFiberThread::refcount, ns3::RUNNING, ns3::PthreadFiber::stack_copy, ns3::PthreadFiberThread::stack_size, ns3::PthreadFiber::state, ns3::PthreadFiber::thread, ns3::PthreadFiberThread::thread_started, and ns3::PthreadFiberThread::trampoline.

Referenced by Create().

+ Here is the caller graph for this function:

void ns3::PthreadFiberManager::Delete ( struct Fiber fiber)
virtual
Parameters
contextto delete

Release any ressource associated to this context. Obviously, this method must be called from another context than the one which is being deleted.

Implements ns3::FiberManager.

Definition at line 448 of file pthread-fiber-manager.cc.

References ns3::PthreadFiberThread::condvar, ns3::DESTROY, ns3::PthreadFiberThread::func, ns3::PthreadFiberThread::mutex, ns3::PthreadFiberThread::previous, ns3::PthreadFiberThread::refcount, ns3::PthreadFiber::stack_copy, ns3::PthreadFiber::state, ns3::PthreadFiber::thread, ns3::PthreadFiberThread::thread, and ns3::PthreadFiberThread::thread_started.

uint32_t ns3::PthreadFiberManager::GetStackSize ( struct Fiber fiber) const
virtual
Returns
size of stack allocated in fiber.

Implements ns3::FiberManager.

Definition at line 507 of file pthread-fiber-manager.cc.

References ns3::PthreadFiberThread::stack_size, and ns3::PthreadFiber::thread.

void ns3::PthreadFiberManager::RestoreFiber ( struct PthreadFiber fiber)
private
void * ns3::PthreadFiberManager::SelfStackBottom ( void  )
staticprivate

Definition at line 304 of file pthread-fiber-manager.cc.

Referenced by Clone(), Run(), and Yield().

+ Here is the caller graph for this function:

void ns3::PthreadFiberManager::SetSwitchNotification ( void(*)(void)  fn)
virtual
Parameters
fna function which will be invoked whenever SwitchTo is invoked, just before it returns to the destination fiber.

Implements ns3::FiberManager.

Definition at line 513 of file pthread-fiber-manager.cc.

References m_notifySwitch.

void ns3::PthreadFiberManager::Start ( struct PthreadFiber fiber)
private

Definition at line 310 of file pthread-fiber-manager.cc.

References Run(), ns3::PthreadFiberThread::stack_size, ns3::PthreadFiber::thread, ns3::PthreadFiberThread::thread, and ns3::PthreadFiberThread::thread_started.

Referenced by Wakeup().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::PthreadFiberManager::SwitchTo ( struct Fiber from,
const struct Fiber to 
)
virtual
Parameters
fromfrom context
toto context

This function saves the caller's context into the from context and restores the current context from the to context. The first time this function is called, it is usually called with a from set to a context obtained through CreateFromCaller and with a to set to a context obtained through Create.

Implements ns3::FiberManager.

Definition at line 486 of file pthread-fiber-manager.cc.

References ns3::PthreadFiberThread::func, m_notifySwitch, ns3::PthreadFiber::thread, Wakeup(), and Yield().

+ Here is the call graph for this function:

void ns3::PthreadFiberManager::Wakeup ( struct PthreadFiber fiber)
private

Definition at line 328 of file pthread-fiber-manager.cc.

References ns3::PthreadFiberThread::condvar, ns3::PthreadFiberThread::mutex, ns3::PthreadFiberThread::next, ns3::RUNNING, Start(), ns3::PthreadFiber::state, ns3::PthreadFiber::thread, and ns3::PthreadFiberThread::thread_started.

Referenced by SwitchTo().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

void(* ns3::PthreadFiberManager::m_notifySwitch)(void)
private

Definition at line 35 of file pthread-fiber-manager.h.

Referenced by SetSwitchNotification(), and SwitchTo().

StackTrampoline* ns3::PthreadFiberManager::m_trampoline
private

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