#include <pthread-fiber-manager.h>
Public Member Functions | |
PthreadFiberManager () | |
virtual | ~PthreadFiberManager () |
virtual struct Fiber * | Clone (struct Fiber *fiber) |
virtual struct Fiber * | Create (void(*callback)(void *), void *context, uint32_t stackSize) |
virtual struct Fiber * | CreateFromCaller (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) |
![]() | |
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) |
StackTrampoline * | m_trampoline |
Definition at line 13 of file pthread-fiber-manager.h.
ns3::PthreadFiberManager::PthreadFiberManager | ( | ) |
Definition at line 240 of file pthread-fiber-manager.cc.
References m_trampoline.
|
virtual |
Definition at line 246 of file pthread-fiber-manager.cc.
References m_trampoline.
Reimplemented from ns3::FiberManager.
Definition at line 253 of file pthread-fiber-manager.cc.
References ns3::MemoryBounds::AddBound(), ns3::MemoryBounds::GetSize(), ns3::MemoryBounds::GetStart(), ns3::PthreadFiberThread::refcount, SelfStackBottom(), ns3::SLEEP, ns3::PthreadFiber::stack_bounds, ns3::PthreadFiberThread::stack_bounds, ns3::PthreadFiber::stack_copy, ns3::PthreadFiberThread::stack_size, ns3::PthreadFiber::state, ns3::PthreadFiber::thread, VALGRIND_MAKE_MEM_DEFINED, and ns3::PthreadFiber::yield_env.
|
readvirtual |
callback | function to use as main loop for the newly-created fiber |
stackSize | size of the stack to allocate for this fiber. |
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.
|
readvirtual |
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().
|
virtual |
context | to 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.
|
virtual |
Implements ns3::FiberManager.
Definition at line 507 of file pthread-fiber-manager.cc.
References ns3::PthreadFiberThread::stack_size, and ns3::PthreadFiber::thread.
|
private |
|
staticprivate |
Definition at line 393 of file pthread-fiber-manager.cc.
References ns3::MemoryBounds::AddBound(), ns3::PthreadFiberThread::condvar, ns3::PthreadFiberThread::context, ns3::DESTROY, ns3::PthreadFiberThread::func, ns3::PthreadFiberThread::initial_env, ns3::PthreadFiberThread::mutex, SelfStackBottom(), ns3::PthreadFiberThread::stack_bounds, ns3::PthreadFiber::state, ns3::PthreadFiber::thread, and ns3::PthreadFiberThread::thread.
Referenced by Start().
|
staticprivate |
Definition at line 304 of file pthread-fiber-manager.cc.
Referenced by Clone(), Run(), and Yield().
|
virtual |
fn | a 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.
|
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().
from | from context |
to | to 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().
|
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().
|
private |
Definition at line 354 of file pthread-fiber-manager.cc.
References ns3::MemoryBounds::AddBound(), ns3::PthreadFiberThread::condvar, ns3::DESTROY, ns3::PthreadFiberThread::initial_env, ns3::PthreadFiberThread::mutex, ns3::PthreadFiberThread::previous, ns3::RUNNING, SelfStackBottom(), ns3::SLEEP, ns3::PthreadFiber::stack_bounds, ns3::PthreadFiberThread::stack_bounds, ns3::PthreadFiber::state, ns3::PthreadFiber::thread, and ns3::PthreadFiber::yield_env.
Referenced by SwitchTo().
|
private |
Definition at line 35 of file pthread-fiber-manager.h.
Referenced by SetSwitchNotification(), and SwitchTo().
|
private |
Definition at line 36 of file pthread-fiber-manager.h.
Referenced by CreateFromCaller(), PthreadFiberManager(), and ~PthreadFiberManager().