/* *Thisistheplatform-specificimplementationunderpinning *theParkEventclass,whichitselfunderpinsJava-levelmonitor *operations.Seepark.hppfordetails. *Theseeventobjectsaretype-stableandimmortal-weneverdeletethem. *Eventsareassociatedwithathreadforthelifetimeofthethread.
*/ class PlatformEvent : public CHeapObj<mtSynchronizer> { private: double cachePad[4]; // Increase odds that _mutex is sole occupant of cache line volatileint _event; // Event count/permit: -1, 0 or 1 volatileint _nParked; // Indicates if associated thread is blocked: 0 or 1
pthread_mutex_t _mutex[1]; // Native mutex for locking
pthread_cond_t _cond[1]; // Native condition variable for blocking double postPad[2];
protected: // TODO-FIXME: make dtor private
~PlatformEvent() { guarantee(false, "invariant"); } // immortal so can't delete
public:
PlatformEvent(); void park(); int park(jlong millis); void unpark();
// Use caution with reset() and fired() -- they may require MEMBARs void reset() { _event = 0; } int fired() { return _event; }
};
// JSR166 support // PlatformParker provides the platform dependent base class for the // Parker class. It basically provides the internal data structures: // - mutex and convars // which are then used directly by the Parker methods defined in the OS // specific implementation files. // There is significant overlap between the funcionality supported in the // combination of Parker+PlatformParker and PlatformEvent (above). If Parker // were more like ObjectMonitor we could use PlatformEvent in both (with some // API updates of course). But Parker methods use fastpaths that break that // level of encapsulation - so combining the two remains a future project.
class PlatformParker {
NONCOPYABLE(PlatformParker); protected: enum {
REL_INDEX = 0,
ABS_INDEX = 1
}; volatileint _counter; int _cur_index; // which cond is in use: -1, 0, 1
pthread_mutex_t _mutex[1];
pthread_cond_t _cond[2]; // one for relative times and one for absolute
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.