[Tinyos-devel] Proposal for VariableSizedQueueC component

Kevin Klues klueska at gmail.com
Tue Sep 18 16:06:30 PDT 2007


I propose the introduction of a VariableSizedQueueC component with the
following signature:

generic module VariableSizedQueueC(typedef queue_t, typedef
queue_size_t @integer(), const QUEUE_SIZE) {
  provides interface VariableSizedQueue<queue_t, queue_size_t> as Queue;
}

All of the logic previously found in QueueC will be implemented in
this component, with the definition of QueueC changing to:

generic configuration QueueC(typedef queue_t, uint8_t QUEUE_SIZE) {
  provides interface Queue<queue_t>;
}
implementation {
  components new QueueP(queue_t);
  components new VariableSizedQueueC(queue_t, uint8_t, QUEUE_SIZE);
  Queue = QueueP;
  QueueP.VariableSizedQueue -> VariableSizedQueueC;
}

Where QueueP just maps through calls on the Queue interface to the
VariableSizedQueue interface defined with a queue size type of
uint8_t.

generic module QueueP(typedef queue_t) {
  provides {
  	interface Queue<queue_t>;
  }
  uses {
  	interface VariableSizedQueue<queue_t, uint8_t>;
  }
}
implementation {
  command bool Queue.empty() {
    return call VariableSizedQueue.empty();
  }
  command uint8_t Queue.size() {
    return call VariableSizedQueue.size();
  }
  command uint8_t Queue.maxSize() {
    return call VariableSizedQueue.maxSize();
  }
  command queue_t Queue.head() {
    return call VariableSizedQueue.head();
  }
  command queue_t Queue.dequeue() {
    return call VariableSizedQueue.dequeue();
  }
  command error_t Queue.enqueue(queue_t newVal) {
    return call VariableSizedQueue.enqueue(newVal);
  }
  command queue_t Queue.element(uint8_t idx) {
    return call VariableSizedQueue.element(idx);
  }
}

Making these changes doesn't break existing code in any way, but will
now allows users to use a VariableSizedQueue if they would like to
have queues larger than 256 elements.

Thoughts?

-- 
~Kevin


More information about the Tinyos-devel mailing list