Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
        CircularBuffer* que;
        KeyType a = 101;
        int isEmpty, i;
 
        CircularBufferInit(&que, BUFFER_SIZE);

	fprintf(stderr,"After Init\n");
        CircularBufferPrint(que);
 
        for(i=1; i<=4; i++)
        {  
            a=10*i;
            printf("\n\n===\nTest: Insert %d-%d\n", a, a+NUM_OF_ELEMS-1);
            while(! CircularBufferEnque(que, a++));
 
            CircularBufferPrint(que);
            printf("\nRX%d:", i);
            a=0;
            isEmpty = CircularBufferDeque(que, &a); 
            while (!isEmpty)
            {
                printf("%02d ", a);
                a=0;
                isEmpty = CircularBufferDeque(que, &a); 
            }
            //CircularBufferPrint(que);
        }
        CircularBufferPrint(que);
 
	fprintf(stderr,"\n");
        free(que);
        return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
    CircularBuffer* que;
    KeyType a = 0;
    int isEmpty;
    CircularBufferInit(&que, BUFFER_SIZE);

    while(! CircularBufferEnque(que, a++));

    do {
        isEmpty = CircularBufferDeque(que, &a);
        printf("%02d ", a);
    } while (!isEmpty);
    printf("\n");
    free(que);
    return 0;
}
Ejemplo n.º 3
0
int main()
{
    KeyType counter = 0;
    KeyType thisint = 0;
    CircularBuffer* que;
    CircularBufferInit(&que, 4);
    while(true) {   // this is the third thread
        counter++;
        if (enqueue) {
            CircularBufferEnque(que, counter);
        }
        if (dequeue) {
            CircularBufferDeque(que, &thisint);
        }
        lcd.cls();
        lcd.locate(0,0);
        lcd.printf("Count: %d  Popped: %d",counter, thisint);
        lcd.locate(0,15);
        lcd.printf("%d   %d   %d   %d", (que->keys)[0], (que->keys)[1], (que->keys)[2], (que->keys)[3]);
        wait(1.0);
    }
}