ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ActivityManager Class Reference

#include <ActivityManager.hpp>

Collaboration diagram for ActivityManager:
[legend]

Static Public Member Functions

static void live (size_t)
 
static void liveGeneral (int reason)
 
static void addWaitingActivity (RexxActivity *a, bool release)
 
static bool hasWaiters ()
 
static RexxActivityfindActivity ()
 
static RexxActivityfindActivity (thread_id_t)
 
static RexxActivitygetActivity ()
 
static void returnActivity (RexxActivity *)
 
static void activityEnded (RexxActivity *)
 
static void shutdown ()
 
static void checkShutdown ()
 
static void createInterpreter ()
 
static void terminateInterpreter ()
 
static void lockKernel ()
 
static void unlockKernel ()
 
static bool lockKernelImmediate ()
 
static void createLocks ()
 
static void closeLocks ()
 
static void init ()
 
static RexxActivationnewActivation (RexxActivity *activity, RoutineClass *routine, RexxCode *code, RexxString *calltype, RexxString *environment, int context)
 
static RexxActivationnewActivation (RexxActivity *activity, RexxActivation *parent, RexxCode *code, int context)
 
static RexxActivationnewActivation (RexxActivity *activity, RexxMethod *method, RexxCode *code)
 
static RexxNativeActivationnewNativeActivation (RexxActivity *activity, RexxActivation *parent)
 
static RexxNativeActivationnewNativeActivation (RexxActivity *activity)
 
static RexxActivitycreateNewActivity ()
 
static RexxActivitycreateCurrentActivity ()
 
static RexxActivitycreateNewActivity (RexxActivity *)
 
static void haltAllActivities (RexxString *)
 
static void traceAllActivities (bool on)
 
static bool setActivityTrace (thread_id_t thread_id, bool on_or_off)
 
static void clearActivityPool ()
 
static bool poolActivity (RexxActivity *activity)
 
static bool haltActivity (thread_id_t thread_id, RexxString *description)
 
static void yieldCurrentActivity ()
 
static void exit (int retcode)
 
static void relinquish (RexxActivity *activity)
 
static RexxActivitygetRootActivity ()
 
static void returnRootActivity (RexxActivity *activity)
 
static RexxActivityattachThread ()
 
static RexxObjectgetLocalEnvironment (RexxString *name)
 
static RexxDirectorygetLocal ()
 
static void postTermination ()
 
static void waitForTermination ()
 

Static Public Attributes

static RexxActivity *volatile currentActivity = OREF_NULL
 

Protected Types

enum  { MAX_THREAD_POOL_SIZE = 5 }
 

Static Protected Attributes

static RexxListactiveActivities
 
static RexxListavailableActivities = OREF_NULL
 
static RexxListallActivities = OREF_NULL
 
static RexxIdentityTablesubClasses
 
static bool processTerminating = false
 
static size_t interpreterInstances = 0
 
static SysMutex kernelSemaphore
 
static SysSemaphore terminationSem
 
static volatile bool sentinel = false
 
static std::deque< RexxActivity * > waitingActivities
 

Detailed Description

Definition at line 49 of file ActivityManager.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
MAX_THREAD_POOL_SIZE 

Definition at line 108 of file ActivityManager.hpp.

Member Function Documentation

◆ activityEnded()

void ActivityManager::activityEnded ( RexxActivity activityObject)
static

Return an activity to the activity pool.

Parameters
activityObjectThe released activity.

Definition at line 642 of file ActivityManager.cpp.

References allActivities, RexxList::items(), postTermination(), processTerminating, and RexxList::removeItem().

Referenced by RexxActivity::runThread().

◆ addWaitingActivity()

void ActivityManager::addWaitingActivity ( RexxActivity waitingAct,
bool  release 
)
static

Add a waiting activity to the waiting queue.

Parameters
waitingActThe activity to queue up.
releaseIf true, the kernel lock should be released on completion.

Definition at line 125 of file ActivityManager.cpp.

References RexxActivity::clearWait(), currentActivity, RexxActivity::getNumericSettings(), hasWaiters(), lockKernel(), ResourceSection::reacquire(), ResourceSection::release(), sentinel, Numerics::setCurrentSettings(), unlockKernel(), RexxActivity::waitForDispatch(), waitingActivities, and SysActivity::yield().

Referenced by relinquish(), and RexxActivity::requestAccess().

◆ attachThread()

RexxActivity * ActivityManager::attachThread ( )
static

Attach an activity to an interpreter instance

Parameters
instanceThe interpreter instance involved.
Returns
Either an existing activity, or a new activity created for this thread.

Definition at line 733 of file ActivityManager.cpp.

References createCurrentActivity(), currentActivity, findActivity(), lockKernel(), OREF_NULL, RexxActivity::requestAccess(), sentinel, RexxActivity::setNestedActivity(), RexxActivity::setSuspended(), and unlockKernel().

Referenced by InterpreterInstance::attachThread().

◆ checkShutdown()

static void ActivityManager::checkShutdown ( )
static

◆ clearActivityPool()

void ActivityManager::clearActivityPool ( )
static

◆ closeLocks()

void ActivityManager::closeLocks ( )
static

Create the global kernel lock for the ActivityManager.

Definition at line 578 of file ActivityManager.cpp.

References SysSemaphore::close(), SysMutex::close(), kernelSemaphore, and terminationSem.

Referenced by Interpreter::processShutdown().

◆ createCurrentActivity()

RexxActivity * ActivityManager::createCurrentActivity ( )
static

Create an activity object for the current thread.

Returns

Definition at line 367 of file ActivityManager.cpp.

References allActivities, and RexxList::append().

Referenced by attachThread(), and getRootActivity().

◆ createInterpreter()

void ActivityManager::createInterpreter ( )
static

Terminate an interpreter instance. This starts process shutdown if the last instance goes away.

Definition at line 203 of file ActivityManager.cpp.

References interpreterInstances.

◆ createLocks()

void ActivityManager::createLocks ( )
static

Create the global kernel lock for the ActivityManager.

Definition at line 567 of file ActivityManager.cpp.

References SysSemaphore::create(), SysMutex::create(), kernelSemaphore, SysSemaphore::reset(), and terminationSem.

Referenced by Interpreter::processStartup().

◆ createNewActivity() [1/2]

RexxActivity * ActivityManager::createNewActivity ( )
static

Obtain a new activity for running on a separate thread.

Returns
The created (or pooled) activity object.

Definition at line 336 of file ActivityManager.cpp.

References allActivities, RexxList::append(), availableActivities, OREF_NULL, ResourceSection::reacquire(), ResourceSection::release(), RexxList::removeFirstItem(), and RexxActivity::reset().

Referenced by createNewActivity(), new_activity(), and InterpreterInstance::spawnActivity().

◆ createNewActivity() [2/2]

RexxActivity * ActivityManager::createNewActivity ( RexxActivity parent)
static

Clone off an activity from an existing activity. Used for message start() are early reply operations.

Parameters
parentThe currently running activity. The activity-specific settings are inherited from the parent.
Returns
A new activity.

Definition at line 389 of file ActivityManager.cpp.

References createNewActivity(), and RexxActivity::inheritSettings().

◆ exit()

void ActivityManager::exit ( int  retcode)
static

Definition at line 535 of file ActivityManager.cpp.

◆ findActivity() [1/2]

RexxActivity * ActivityManager::findActivity ( )
static

◆ findActivity() [2/2]

◆ getActivity()

RexxActivity * ActivityManager::getActivity ( )
static

Get an already existing activity for the current thread and give it kernel access before returning. This will fail if the thread has not been properly attached.

Returns
The activity for this thread.

Definition at line 776 of file ActivityManager.cpp.

References RexxActivity::enterCurrentThread(), findActivity(), and OREF_NULL.

Referenced by NativeContextBlock::NativeContextBlock().

◆ getLocal()

RexxDirectory * ActivityManager::getLocal ( )
static

Retrieve the current .local directory instance.

Returns
The .local directory for the current activity.

Definition at line 832 of file ActivityManager.cpp.

References currentActivity, RexxActivity::getLocal(), and OREF_NULL.

Referenced by RexxDirectory::atRexx(), and RexxLocal::local().

◆ getLocalEnvironment()

RexxObject * ActivityManager::getLocalEnvironment ( RexxString name)
static

Retrieve a variable from the current local environment object.

Parameters
nameThe name of the environment variable.
Returns
The object stored in .local at the requested name.

Definition at line 817 of file ActivityManager.cpp.

References currentActivity, RexxActivity::getLocalEnvironment(), OREF_NULL, and TheNilObject.

Referenced by Interpreter::findClass(), RexxSource::findClass(), and Interpreter::getCurrentQueue().

◆ getRootActivity()

RexxActivity * ActivityManager::getRootActivity ( )
static

◆ haltActivity()

bool ActivityManager::haltActivity ( thread_id_t  thread_id,
RexxString description 
)
static

Definition at line 447 of file ActivityManager.cpp.

References findActivity(), RexxActivity::halt(), and OREF_NULL.

Referenced by RexxHaltThread().

◆ haltAllActivities()

static void ActivityManager::haltAllActivities ( RexxString )
static

◆ hasWaiters()

static bool ActivityManager::hasWaiters ( )
inlinestatic

Definition at line 56 of file ActivityManager.hpp.

References waitingActivities.

Referenced by addWaitingActivity(), and relinquish().

◆ init()

void ActivityManager::init ( void  )
static

Initialize the activity manager when the interpreter starts up.

Definition at line 79 of file ActivityManager.cpp.

References allActivities, availableActivities, currentActivity, new_list(), and OREF_NULL.

Referenced by RexxMemory::createImage(), and RexxMemory::restore().

◆ live()

void ActivityManager::live ( size_t  liveMark)
static

Definition at line 86 of file ActivityManager.cpp.

References allActivities, availableActivities, and memory_mark.

Referenced by RexxMemory::live().

◆ liveGeneral()

void ActivityManager::liveGeneral ( int  reason)
static

◆ lockKernel()

void ActivityManager::lockKernel ( )
static

Definition at line 543 of file ActivityManager.cpp.

References kernelSemaphore, and SysMutex::request().

Referenced by addWaitingActivity(), attachThread(), and getRootActivity().

◆ lockKernelImmediate()

bool ActivityManager::lockKernelImmediate ( )
static

Try a fast request for the kernel. This requires A) there be no waiting activities and B) that it be possible to request the semaphore without waiting.

Returns
true if the semaphore was obtained, false if the kernel is not locked by this activity.

Definition at line 593 of file ActivityManager.cpp.

References kernelSemaphore, SysMutex::requestImmediate(), and waitingActivities.

Referenced by RexxActivity::requestAccess().

◆ newActivation() [1/3]

RexxActivation * ActivityManager::newActivation ( RexxActivity activity,
RexxActivation parent,
RexxCode code,
int  context 
)
static

Create a new activation for an internal level call (internal call or interpreted execution).

Parameters
activityThe activity we're running on.
parentThe parent activation. OREF_NULL is used if this is a top-level call.
codeThe code object associated with the method.
contextThe context of the invocation.
Returns
The newly created activation.

Definition at line 274 of file ActivityManager.cpp.

◆ newActivation() [2/3]

RexxActivation * ActivityManager::newActivation ( RexxActivity activity,
RexxMethod method,
RexxCode code 
)
static

Create a new activation for a method invocation (vs. a program or routine call)

Parameters
activityThe activity we're running on.
methodThe method object being invoked.
codeThe code object associated with the method.
Returns
The newly created activation.

Definition at line 292 of file ActivityManager.cpp.

◆ newActivation() [3/3]

RexxActivation * ActivityManager::newActivation ( RexxActivity activity,
RoutineClass routine,
RexxCode code,
RexxString calltype,
RexxString environment,
int  context 
)
static

Create a new activation for a toplevel activation using a routine (vs. a method invocation).

Parameters
activityThe activity we're running on.
routineThe routine object we're calling.
codeThe code object associated with the method.
calltypeThe type of call being made.
environmentThe initial address environment.
contextThe context of the invocation.
Returns
The newly created activation.

Definition at line 254 of file ActivityManager.cpp.

Referenced by RexxCode::call(), RexxActivation::debugInterpret(), RexxActivation::internalCall(), RexxActivation::internalCallTrap(), RexxActivation::interpret(), and RexxCode::run().

◆ newNativeActivation() [1/2]

RexxNativeActivation * ActivityManager::newNativeActivation ( RexxActivity activity)
static

Create a new activation for a a native external call stack

Parameters
activityThe activity we're running on.
Returns
The newly created activation.

Definition at line 323 of file ActivityManager.cpp.

◆ newNativeActivation() [2/2]

RexxNativeActivation * ActivityManager::newNativeActivation ( RexxActivity activity,
RexxActivation parent 
)
static

Create a new activation for a a native external call stack

Parameters
activityThe activity we're running on.
parentThe parent activation.
Returns
The newly created activation.

Definition at line 308 of file ActivityManager.cpp.

Referenced by RexxNativeRoutine::call(), RegisteredRoutine::call(), RexxActivity::createNewActivationStack(), RexxActivity::exitKernel(), RexxNativeMethod::run(), and RexxActivity::run().

◆ poolActivity()

bool ActivityManager::poolActivity ( RexxActivity activity)
static

Return an activity to the available pool. If we're in the process of shutting down, or have too many pool activities, we'll return false to tell the activity to completely shut things down.

Parameters
activityThe activity we're adding back to the available pool.
Returns
true if this was pooled, false if the thread should not wait for more work.

Definition at line 426 of file ActivityManager.cpp.

References allActivities, RexxList::append(), availableActivities, RexxActivity::cleanupActivityResources(), RexxList::items(), MAX_THREAD_POOL_SIZE, processTerminating, and RexxList::removeItem().

Referenced by InterpreterInstance::poolActivity().

◆ postTermination()

static void ActivityManager::postTermination ( )
inlinestatic

Definition at line 97 of file ActivityManager.hpp.

References SysSemaphore::post(), and terminationSem.

Referenced by activityEnded().

◆ relinquish()

void ActivityManager::relinquish ( RexxActivity activity)
static

Switch the active activity if there are other activities waiting to run.

Parameters
activityThe current active activity.

Definition at line 798 of file ActivityManager.cpp.

References addWaitingActivity(), and hasWaiters().

Referenced by RexxActivity::relinquish().

◆ returnActivity()

void ActivityManager::returnActivity ( RexxActivity activityObject)
static

Return an activity to the activity pool.

Parameters
activityObjectThe released activity.

Definition at line 611 of file ActivityManager.cpp.

References allActivities, OREF_NULL, RexxList::removeItem(), and RexxActivity::setSuspended().

Referenced by RexxMemory::createImage(), and InterpreterInstance::detachThread().

◆ returnRootActivity()

void ActivityManager::returnRootActivity ( RexxActivity activity)
static

return a root activity when an interpreter instance terminates.

Definition at line 710 of file ActivityManager.cpp.

References allActivities, RexxActivity::cleanupActivityResources(), RexxActivity::detachInstance(), and RexxList::removeItem().

Referenced by InterpreterInstance::terminate().

◆ setActivityTrace()

bool ActivityManager::setActivityTrace ( thread_id_t  thread_id,
bool  on_or_off 
)
static

Definition at line 466 of file ActivityManager.cpp.

References findActivity(), OREF_NULL, and RexxActivity::setTrace().

Referenced by RexxResetThreadTrace(), and RexxSetThreadTrace().

◆ shutdown()

void ActivityManager::shutdown ( )
static

Shutdown the activity manager and initiate interpreter termination.

Definition at line 228 of file ActivityManager.cpp.

References clearActivityPool(), and processTerminating.

Referenced by terminateInterpreter().

◆ terminateInterpreter()

void ActivityManager::terminateInterpreter ( )
static

Terminate an interpreter instance. This starts process shutdown if the last instance goes away.

Definition at line 213 of file ActivityManager.cpp.

References interpreterInstances, and shutdown().

◆ traceAllActivities()

static void ActivityManager::traceAllActivities ( bool  on)
static

◆ unlockKernel()

void ActivityManager::unlockKernel ( )
static

◆ waitForTermination()

static void ActivityManager::waitForTermination ( )
inlinestatic

Definition at line 102 of file ActivityManager.hpp.

References terminationSem, and SysSemaphore::wait().

◆ yieldCurrentActivity()

void ActivityManager::yieldCurrentActivity ( )
static

Definition at line 485 of file ActivityManager.cpp.

References currentActivity, OREF_NULL, and RexxActivity::yield().

Member Data Documentation

◆ activeActivities

RexxList* ActivityManager::activeActivities
staticprotected

Definition at line 114 of file ActivityManager.hpp.

◆ allActivities

◆ availableActivities

RexxList * ActivityManager::availableActivities = OREF_NULL
staticprotected

◆ currentActivity

RexxActivity *volatile ActivityManager::currentActivity = OREF_NULL
static

Definition at line 95 of file ActivityManager.hpp.

Referenced by addWaitingActivity(), RexxDirectory::allItems(), RexxDirectory::at(), RexxDirectory::atRexx(), attachThread(), RexxNativeActivation::callNativeRoutine(), CalloutBlock::CalloutBlock(), RexxNativeActivation::callRegisteredRoutine(), RoutineClass::callRexx(), RoutineClass::callWithRexx(), RexxObject::checkPrivate(), RexxStemVariable::clearGuard(), RexxParseVariable::clearGuard(), RexxCompoundVariable::clearGuard(), RexxMemory::createImage(), RexxObject::decodeMessageName(), RexxActivity::enterCurrentThread(), RexxSource::error(), RexxSource::errorLine(), RexxSource::errorPosition(), RexxSource::errorToken(), RexxExpressionFunction::evaluate(), RexxInstructionQueue::execute(), RexxInstructionGuard::execute(), RexxInstructionParse::execute(), RexxInstructionCall::execute(), RexxActivation::exitFrom(), getLocal(), getLocalEnvironment(), getRootActivity(), RexxDirectory::indexRexx(), init(), RexxSource::install(), RexxActivation::interpret(), lastMessageName(), lastMethod(), LibraryPackage::loadPackage(), PackageClass::loadPackage(), RexxNumberString::maxMin(), RexxObject::messageSend(), RexxMethod::newMethodObject(), PackageClass::newRexx(), RoutineClass::newRoutineObject(), RexxVariable::notify(), RexxObject::processProtectedMethod(), RexxObject::processUnknown(), ProtectedObject::ProtectedObject(), RexxActivation::raise(), RexxActivity::releaseAccess(), reportCondition(), reportException(), reportNomethod(), RexxActivity::requestAccess(), RexxObject::requestString(), RexxMessage::result(), RexxNativeActivation::run(), RexxActivity::run(), RexxObject::run(), RexxActivity::runThread(), RexxMemory::runUninits(), RexxMessage::send(), RexxMessage::sendNotification(), RexxParseVariable::setGuard(), RexxStemVariable::setGuard(), RexxCompoundVariable::setGuard(), RexxMessage::start(), RexxDirectory::supplier(), RexxSource::traceBack(), RexxSource::translate(), LibraryPackage::unload(), unlockKernel(), UnsafeBlock::UnsafeBlock(), RexxActivity::updateFrameMarkers(), and yieldCurrentActivity().

◆ interpreterInstances

size_t ActivityManager::interpreterInstances = 0
staticprotected

Definition at line 121 of file ActivityManager.hpp.

Referenced by createInterpreter(), and terminateInterpreter().

◆ kernelSemaphore

SysMutex ActivityManager::kernelSemaphore
staticprotected

◆ processTerminating

bool ActivityManager::processTerminating = false
staticprotected

Definition at line 120 of file ActivityManager.hpp.

Referenced by activityEnded(), poolActivity(), and shutdown().

◆ sentinel

volatile bool ActivityManager::sentinel = false
staticprotected

◆ subClasses

RexxIdentityTable* ActivityManager::subClasses
staticprotected

Definition at line 119 of file ActivityManager.hpp.

◆ terminationSem

SysSemaphore ActivityManager::terminationSem
staticprotected

Definition at line 124 of file ActivityManager.hpp.

Referenced by closeLocks(), createLocks(), postTermination(), and waitForTermination().

◆ waitingActivities

std::deque< RexxActivity * > ActivityManager::waitingActivities
staticprotected

Definition at line 126 of file ActivityManager.hpp.

Referenced by addWaitingActivity(), hasWaiters(), and lockKernelImmediate().


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