ActivityManager Class Reference

#include <ActivityManager.hpp>

Static Public Member Functions

static void live (size_t)
 
static void liveGeneral (int reason)
 
static void addWaitingActivity (RexxActivity *a, bool release)
 
static wholenumber_t addWaitingActivityCounter ()
 
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, RexxActivation *parent, RoutineClass *routine, RexxCode *code, RexxString *calltype, RexxString *environment, int context)
 
static RexxActivationnewActivation (RexxActivity *activity, RexxActivation *parent, RexxCode *code, int context)
 
static RexxActivationnewActivation (RexxActivity *activity, RexxActivation *parent, 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 wholenumber_t yieldCounter ()
 
static void exit (int retcode)
 
static void relinquish (RexxActivity *activity)
 
static wholenumber_t relinquishCounter ()
 
static RexxActivitygetRootActivity ()
 
static void returnRootActivity (RexxActivity *activity)
 
static RexxActivityattachThread ()
 
static RexxObjectgetLocalEnvironment (RexxString *name)
 
static RexxDirectorygetLocal ()
 
static void postTermination ()
 
static void waitForTermination (const char *ds, int di)
 

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 111 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 656 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 132 of file ActivityManager.cpp.

References addWaitingActivityCount, 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().

◆ addWaitingActivityCounter()

wholenumber_t ActivityManager::addWaitingActivityCounter ( )
static

Definition at line 121 of file ActivityManager.cpp.

References addWaitingActivityCount.

Referenced by RexxActivation::rexxVariable().

◆ 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 747 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 592 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 375 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 211 of file ActivityManager.cpp.

References interpreterInstances.

◆ createLocks()

void ActivityManager::createLocks ( )
static

Create the global kernel lock for the ActivityManager.

Definition at line 581 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 344 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 397 of file ActivityManager.cpp.

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

◆ exit()

void ActivityManager::exit ( int  retcode)
static

Definition at line 549 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 790 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 854 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 839 of file ActivityManager.cpp.

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

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

◆ getRootActivity()

RexxActivity * ActivityManager::getRootActivity ( )
static

◆ haltActivity()

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

Definition at line 455 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 57 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 557 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 607 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 282 of file ActivityManager.cpp.

◆ newActivation() [2/3]

RexxActivation * ActivityManager::newActivation ( RexxActivity activity,
RexxActivation parent,
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 300 of file ActivityManager.cpp.

◆ newActivation() [3/3]

RexxActivation * ActivityManager::newActivation ( RexxActivity activity,
RexxActivation parent,
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 262 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 331 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 316 of file ActivityManager.cpp.

Referenced by RexxNativeRoutine::call(), RegisteredRoutine::call(), RexxActivity::createNewActivationStack(), RexxActivity::exitKernel(), RexxActivity::run(), and RexxNativeMethod::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 434 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 100 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 819 of file ActivityManager.cpp.

References addWaitingActivity(), hasWaiters(), and relinquishCount.

Referenced by RexxActivity::relinquish().

◆ relinquishCounter()

wholenumber_t ActivityManager::relinquishCounter ( )
static

Definition at line 808 of file ActivityManager.cpp.

References relinquishCount.

Referenced by RexxActivation::rexxVariable().

◆ returnActivity()

void ActivityManager::returnActivity ( RexxActivity activityObject)
static

Return an activity to the activity pool.

Parameters
activityObjectThe released activity.

Definition at line 625 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 724 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 474 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 236 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 221 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 ( const char *  ds,
int  di 
)
inlinestatic

Definition at line 105 of file ActivityManager.hpp.

References terminationSem, and SysSemaphore::wait().

◆ yieldCounter()

wholenumber_t ActivityManager::yieldCounter ( )
static

Definition at line 508 of file ActivityManager.cpp.

References SysActivity::yieldCounter().

Referenced by RexxActivation::rexxVariable().

◆ yieldCurrentActivity()

void ActivityManager::yieldCurrentActivity ( )
static

Definition at line 493 of file ActivityManager.cpp.

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

Member Data Documentation

◆ activeActivities

RexxList* ActivityManager::activeActivities
staticprotected

Definition at line 117 of file ActivityManager.hpp.

◆ allActivities

◆ availableActivities

RexxList * ActivityManager::availableActivities = OREF_NULL
staticprotected

◆ currentActivity

RexxActivity *volatile ActivityManager::currentActivity = OREF_NULL
static

Definition at line 98 of file ActivityManager.hpp.

Referenced by addWaitingActivity(), RexxDirectory::allIndexesItems(), RexxDirectory::allItems(), RexxDirectory::appendAllIndexesItemsTo(), RexxDirectory::at(), RexxDirectory::atRexx(), attachThread(), RexxNativeActivation::callNativeRoutine(), CalloutBlock::CalloutBlock(), RexxNativeActivation::callRegisteredRoutine(), RoutineClass::callRexx(), RoutineClass::callWithRexx(), RexxObject::checkPackage(), RexxObject::checkPrivate(), RexxString::checkTE(), RexxCompoundVariable::clearGuard(), RexxStemVariable::clearGuard(), RexxParseVariable::clearGuard(), RexxMemory::createImage(), RexxObject::decodeMessageName(), RexxActivity::enterCurrentThread(), RexxSource::error(), RexxSource::errorLine(), RexxSource::errorPosition(), RexxSource::errorToken(), RexxExpressionFunction::evaluate(), RexxInstructionCall::execute(), RexxInstructionGuard::execute(), RexxInstructionParse::execute(), RexxInstructionQueue::execute(), RexxActivation::exitFrom(), PackageClass::findProgramRexx(), GetConcurrencyInfos(), 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(), RexxText::newText(), RexxVariable::notify(), RexxObject::processProtectedMethod(), RexxObject::processUnknown(), ProtectedObject::ProtectedObject(), RexxDirectory::pushAllIndexesItemsTo(), RexxActivation::raise(), RexxActivity::releaseAccess(), reportCondition(), reportException(), reportNomethod(), RexxActivity::requestAccess(), RexxObject::requestString(), RexxMessage::result(), RexxActivity::run(), RexxNativeActivation::run(), RexxObject::run(), RexxActivity::runThread(), RexxMemory::runUninits(), RexxMessage::send(), RexxMessage::sendNotification(), RexxCompoundVariable::setGuard(), RexxStemVariable::setGuard(), RexxParseVariable::setGuard(), RexxMessage::start(), RexxDirectory::supplier(), RexxSource::traceBack(), RexxSource::translate(), RexxInstructionCall::trap(), LibraryPackage::unload(), unlockKernel(), UnsafeBlock::UnsafeBlock(), RexxActivity::updateFrameMarkers(), and yieldCurrentActivity().

◆ interpreterInstances

size_t ActivityManager::interpreterInstances = 0
staticprotected

Definition at line 124 of file ActivityManager.hpp.

Referenced by createInterpreter(), and terminateInterpreter().

◆ kernelSemaphore

SysMutex ActivityManager::kernelSemaphore
staticprotected

◆ processTerminating

bool ActivityManager::processTerminating = false
staticprotected

Definition at line 123 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 122 of file ActivityManager.hpp.

◆ terminationSem

SysSemaphore ActivityManager::terminationSem
staticprotected

Definition at line 127 of file ActivityManager.hpp.

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

◆ waitingActivities

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

Definition at line 129 of file ActivityManager.hpp.

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


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