Ejemplo n.º 1
0
/*!
 * Queues a new command \a id to the next available slot and returns a reference to that command,
 * so the caller can give it additional parameters. If the queue is full, we simply reallocate some
 * more space up to the max size.
 */
GlCommand &CanvasGlCommandQueue::queueCommand(CanvasGlCommandQueue::GlCommandId id)
{
    // Increase queue size if we run out of space. Note that this should only happen on the first
    // frame on most applications, as we never decrease the allocated size.
    if (m_queuedCount == m_size) {
        // If queue is full and at max size, we need to synchronously execute all commands
        if (m_queuedCount == m_maxSize) {
            emit queueFull();
            // queueFull handling should reset the queue, but in case renderer thread is not available
            // to handle the commands for some reason, let's reset the count. In that case the entire
            // queue is lost, so results may not be pretty, but nothing much can be done about it.
            // Let's at least make sure we don't leak any memory.
            if (m_queuedCount) {
                deleteUntransferedCommandData();
                m_queuedCount = 0;
                clearQuickItemAsTextureList();
            }
        } else {
            m_size += m_size / 2;
            if (m_size > m_maxSize)
                m_size = m_maxSize;
            m_queue.resize(m_size);
        }
    }

    GlCommand &command = m_queue[m_queuedCount++];
    command.id = id;
    command.data = 0;

    return command;
}
Ejemplo n.º 2
0
void ViewFinderWrapper::startCamera()
{
    m_processor = new VideoEncoder(this);
    connect(m_processor, SIGNAL(queueFull()), this, SLOT(onThreadCongested()));
    connect(m_processor, SIGNAL(frameProcessed(QByteArray)),this,SIGNAL(newFrameToSend(QByteArray)));

    m_processor->start();

    m_camera = new QCamera(this);

    QList<QByteArray> cameras = m_camera->availableDevices();

    m_camera = new QCamera(cameras.first());
    m_camera->setViewfinder(new QCameraViewfinder);

    if (m_camera) {
        m_camera->start();
        if(m_camera->state()==QCamera::ActiveState){
            m_cameraActive = true;
            startViewFinder();
        }
        else qDebug()<<"camera didn't start";
    }

}
void addq(element item){
    /* add an item to the queue */
    rear=(rear+1)%MAX_QUEUE_SIZE;//make it circular
    if(rear==front){
        queueFull();/* print error and exit */
    }
    queue[rear]=item;
}
 void VideoWidget::initialize(QStatusBar *bar, SFMViewer *sfmViewer, SceneModel * sceneModel){

     // Connect surface to our slot
     connect(surface, SIGNAL(frameAvailable()), this, SLOT(frameReady()));

     processor = new ProcessingThread(this);
     connect(processor, SIGNAL(frameProcessed()), this, SLOT(onFrameProcessed()));
     connect(processor, SIGNAL(queueFull()), this, SLOT(onThreadCongested()));

	 processor->initialize(bar, sceneModel);
	 processor->setUpdateListener(sfmViewer);

     processor->start();
}
Ejemplo n.º 5
0
NetworkManager::NetworkManager(QString host, int port, QObject *parent) : JsonCommunication(host, port, parent)
{
    m_logged = false;

    m_heartbeatManager = new HeartbeatManager(3,this);
        connect(m_heartbeatManager, SIGNAL(networkRequest(QString)), this, SLOT(serverRequest(QString)));
        connect(m_heartbeatManager, SIGNAL(queueFull()), this, SLOT(forceDisconnect()));
        connect(this,SIGNAL(connectedChanged(bool)),m_heartbeatManager,SLOT(setRunning(bool)));
        connect(this,SIGNAL(hearthbeatReceived(QString)),m_heartbeatManager,SLOT(validate(QString)));

    connect(this,SIGNAL(jsonReceived(QString)),this,SLOT(processJson(QString)));
    connect(this,SIGNAL(serverConnected()),this,SLOT(tryLogin()));
    connect(this,SIGNAL(serverDisconnected()),this,SLOT(setNotLogged()));
}
Ejemplo n.º 6
0
void HeartbeatManager::enqueue(QString uuid)
{
    if (m_queueSize != 0){

        if (m_hbQueue.length() == m_queueSize){

            logm("Heartbeat queue is full");
            emit queueFull();
            m_hbQueue.clear();
        }
        else{

            m_hbQueue.enqueue(uuid);
        }
    }
}
Ejemplo n.º 7
0
Archivo: c203.c Proyecto: adamVass/IAL
void queueUp (tQueue* q, char c) {
/*
** Vlo¾í znak c do fronty. Pokud je fronta plná, o¹etøete chybu voláním
** funkce queueError(QERR_UP). Vkládání do plné fronty se pova¾uje za
** nekorektní operaci. Situace by mohla být øe¹ena i tak, ¾e by operace
** neprovádìla nic, ale v pøípadì pou¾ití takto definované abstrakce by se
** obtí¾nì odhalovaly chyby v algoritmech, které by abstrakci vyu¾ívaly.
**
** Pøi implementaci vyu¾ijte døíve definovaných funkcí queueFull a nextIndex.
*/
	if (queueFull(q))
	{
		queueError(QERR_UP);
		return;
	}
	q->arr[q->b_index] = c;		/* Vlo¾í znak c na prvú voµnú pozíciu vo fronte */
	q->b_index = nextIndex(q->b_index);		/* Nastaví b_index na ïal¹iu voµnú pozíciu vo fronte */
}
Ejemplo n.º 8
0
Archivo: c203.c Proyecto: v-bayer/bcFIT
void queueUp (tQueue* q, char c) {
/*
** Vlo¾í znak c do fronty. Pokud je fronta plná, o¹etøete chybu voláním
** funkce queueError(QERR_UP). Vkládání do plné fronty se pova¾uje za
** nekorektní operaci. Situace by mohla být øe¹ena i tak, ¾e by operace
** neprovádìla nic, ale v pøípadì pou¾ití takto definované abstrakce by se
** obtí¾nì odhalovaly chyby v algoritmech, které by abstrakci vyu¾ívaly.
**
** Pøi implementaci vyu¾ijte døíve definovaných funkcí queueFull a nextIndex.
*/

    if(queueFull(q)){                // Zkontroluj, zda-li neni fronte plna
        queueError(QERR_UP);         // Vyhod chybovou hlasku
        return;                      // Ukonci
    }
    q->arr[q->b_index] = c;             // Vloz znak
    q->b_index = nextIndex(q->b_index); // A posun index posledni volne pozice
}
Ejemplo n.º 9
0
/*----------------------------------------------------------------------------*/
static size_t canWrite(void *object, const void *buffer, size_t length)
{
  assert(length % sizeof(struct CanStandardMessage) == 0);

  struct Can * const interface = object;

  if (interface->mode == MODE_LISTENER)
    return 0;

  LPC_CAN_Type * const reg = interface->base.reg;
  const struct CanStandardMessage *input = buffer;
  const size_t initialLength = length;

  const irqState state = irqSave();

  if (queueEmpty(&interface->txQueue))
  {
    uint32_t status = reg->SR;

    while (length && (status & SR_TBS_MASK))
    {
      /* One of transmit buffers is empty */
      status = sendMessage(interface, (const struct CanMessage *)input, status);

      length -= sizeof(*input);
      ++input;
    }
  }

  while (length && !queueFull(&interface->txQueue))
  {
    struct CanMessage *output;

    queuePop(&interface->pool, &output);
    memcpy(output, input, sizeof(*input));
    queuePush(&interface->txQueue, &output);
    length -= sizeof(*input);
    ++input;
  }

  irqRestore(state);

  return initialLength - length;
}
Ejemplo n.º 10
0
Bool queuePut(Queue *q, unsigned char c)
{
	if (queueFull(q)) {
		return false;
	}
	else {	
		q->buf[q->in] = c;
		
		/* incrementa para a proxima posicao */
		q->in++;

		/* incrementar o numero de elementos da queue */
		q->cnt++;
		
		if(q->in == q->size)
			q->in = 0;
	}
	
	return true;
}
Ejemplo n.º 11
0
void queueUp (tQueue* q, char c) {
/*
** Vlo¾í znak c do fronty. Pokud je fronta plná, o¹etøete chybu voláním
** funkce queueError(QERR_UP). Vkládání do plné fronty se pova¾uje za
** nekorektní operaci. Situace by mohla být øe¹ena i tak, ¾e by operace
** neprovádìla nic, ale v pøípadì pou¾ití takto definované abstrakce by se
** obtí¾nì odhalovaly chyby v algoritmech, které by abstrakci vyu¾ívaly.
**
** Pøi implementaci vyu¾ijte døíve definovaných funkcí queueFull a nextIndex.
*/
	if(queueFull(q) == 0) //fronta nieje plna
	{	
		q->arr[q->b_index] = c; //vlozime znak
		q->b_index = nextIndex(q->b_index); //posunieme sa
	}
	else //fronta je plna vypiseme chybu
	{
		queueError(QERR_UP);
	}
}
Ejemplo n.º 12
0
void queueUp (tQueue* q, char c) {
/*
** Vlo znak c do fronty. Pokud je fronta pln, oetete chybu volnm
** funkce queueError(QERR_UP). Vkldn do pln fronty se povauje za
** nekorektn operaci. Situace by mohla bt eena i tak, e by operace
** neprovdla nic, ale v ppad pouit takto definovan abstrakce by se
** obtn odhalovaly chyby v algoritmech, kter by abstrakci vyuvaly.
**
** Pi implementaci vyuijte dve definovanch funkc queueFull a nextIndex.
*/
    if(queueFull(q) == 0)
    {
        q->arr[q->b_index] = c;
        q->b_index = nextIndex(q->b_index);
    }
    else
    {
        queueError(QERR_UP);
    }

}