Alien-SmokeQt

 view release on metacpan or  search on metacpan

generator/parser/rpp/appendedlist.h  view on Meta::CPAN

enum {
  DynamicAppendedListRevertMask = 0xffffffff - DynamicAppendedListMask
};
/**
 * Manages a repository of items for temporary usage. The items will be allocated with an index on alloc(),
 * and freed on free(index). When freed, the same index will be re-used for a later allocation, thus no real allocations
 * will be happening in most cases.
 * The returned indices will always be ored with DynamicAppendedListMask.
 *
 */
template<class T, bool threadSafe = true>
class TemporaryDataManager {
  public:
    TemporaryDataManager(QString id = QString()) : m_itemsUsed(0), m_itemsSize(0), m_items(0), m_id(id) {
      uint first = alloc();  //Allocate the zero item, just to reserve that index
      Q_ASSERT(first == (uint)DynamicAppendedListMask);
    }
    ~TemporaryDataManager() {
      free(DynamicAppendedListMask); //Free the zero index, so we don't get wrong warnings
      uint cnt = usedItemCount();
      if(cnt) //Don't use kDebug, because that may not work during destruction

generator/parser/rpp/appendedlist.h  view on Meta::CPAN

      //extremely fast. There is special measures in alloc() to make this safe.
      Q_ASSERT(index & DynamicAppendedListMask);

      return *m_items[index & KDevelop::DynamicAppendedListRevertMask];
    }

    ///Allocates an item index, which from now on you can get using getItem, until you call free(..) on the index.
    ///The returned item is not initialized and may contain random older content, so you should clear it after getting it for the first time
    uint alloc() {

      if(threadSafe)
        m_mutex.lock();

      uint ret;
      if(!m_freeIndicesWithData.isEmpty()) {
        ret = m_freeIndicesWithData.pop();
      }else if(!m_freeIndices.isEmpty()) {
        ret = m_freeIndices.pop();
        Q_ASSERT(!m_items[ret]);
        m_items[ret] = new T;
      }else{

generator/parser/rpp/appendedlist.h  view on Meta::CPAN

            }
          }
        }

        ret = m_itemsUsed;
        m_items[m_itemsUsed] = new T;
        ++m_itemsUsed;
        Q_ASSERT(m_itemsUsed <= m_itemsSize);
      }

      if(threadSafe)
        m_mutex.unlock();

      Q_ASSERT(!(ret & DynamicAppendedListMask));

      return ret | DynamicAppendedListMask;
    }

    void free(uint index) {
      Q_ASSERT(index & DynamicAppendedListMask);
      index &= KDevelop::DynamicAppendedListRevertMask;

      if(threadSafe)
        m_mutex.lock();

      freeItem(m_items[index]);

      m_freeIndicesWithData.push(index);

      //Hold the amount of free indices with data between 100 and 200
      if(m_freeIndicesWithData.size() > 200) {
        for(int a = 0; a < 100; ++a) {
          uint deleteIndexData = m_freeIndicesWithData.pop();
          delete m_items[deleteIndexData];
          m_items[deleteIndexData] = 0;
          m_freeIndices.push(deleteIndexData);
        }
      }

      if(threadSafe)
        m_mutex.unlock();
    }

    uint usedItemCount() const {
      uint ret = 0;
      for(uint a = 0; a < m_itemsUsed; ++a)
        if(m_items[a])
          ++ret;
      return ret - m_freeIndicesWithData.size();
    }

generator/parser/rpp/pp-internal.cpp  view on Meta::CPAN

bool rpp::isComment(Stream& input)
{
  uint c1 = input;
  uint c2 = input.peek();

  return c1 == indexFromCharacter('/') && (c2 == indexFromCharacter('/') || c2 == indexFromCharacter('*'));
}

rpp::Stream& rpp::devnull()
{
  // Multithread safe
  static rpp::Stream null;
  return null;
}

smoke/qt/qtcore/tests/test.cpp  view on Meta::CPAN

#include "QtCore/qtextstream.h"

int main(int argc, char ** argv)
{
  QTextStream foo;
}

#endif

#ifdef TEST_QT_NO_THREAD
#include "QtCore/qthread.h"
class QFoo: public QThread
{
public:
    QFoo() {};
    ~QFoo() {};
                void run() {}
};

int main(int argc, char ** argv)
{



( run in 0.325 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )