pike.git / lib / modules / Thread.pmod

version» Context lines:

pike.git/lib/modules/Thread.pmod:869: Inside #if constant(thread_create)
  //! @[ResourceCount], @[MutexKey]   //!   optional class ResourceCountKey {    /*semi*/private ResourceCount parent;       /*semi*/private void create(ResourceCount _parent) {    parent = _parent;    }       /*semi*/private void destroy() { +  MutexKey key = parent->_mutex->lock();    --parent->_count; -  MutexKey lock = parent->_mutex->lock(); +     parent->_cond->signal();    }   }      //! Implements an inverted-semaphore-like resource   //! counter. A thread can poll or perform a blocking wait for the   //! resource-count to drop below a certain @ref{level@}.   //!   //! @seealso   //! @[ResourceCountKey], @[Condition], @[Mutex]
pike.git/lib/modules/Thread.pmod:899: Inside #if constant(thread_create)
   //! @returns    //! True if the resource counter drops to equal or below @ref{level@}.    /*semi*/final int(0..1) drained(void|int level) {    return level >= _count;    }       //! Blocks until the resource-counter dips to max @ref{level@}.    //!    //! @param level    //! The maximum level that is considered drained. -  variant /*semi*/final void wait_till_drained(void|int level) { +  /*semi*/final void wait_till_drained(void|int level) { +  MutexKey key = _mutex->lock();    while (_count > level) // Recheck before allowing further -  _cond->wait(_mutex->lock()); +  _cond->wait(key);    }       //! Increments the resource-counter.    //! @returns    //! A @[ResourceCountKey] to decrement the resource-counter again.    /*semi*/final ResourceCountKey acquire() { -  +  MutexKey key = _mutex->lock();    _count++;    return ResourceCountKey(this);    }       /*semi*/private string _sprintf(int type) {    string res = UNDEFINED;    switch(type) {    case 'O':    res = sprintf("Count: %d", _count);    break;