458 views
in GUI Development by
Hi,

I want to create a queue inside embedded wizard, Like in Core::SystemEvent I want to create a queue based on stack concept. Is there any way of approach we can handle it here, to achieve this

1 Answer

0 votes
by

Hello Dinesh,

if the number of queue elements is deterministic and not too high, I would use an array and two variables as indices into this array to refer the first and the last element. This is the simplest possible approach. Since the size of an array in Embedded Wizard can't still change at the runtime, you would need to configure the array with a size for max. expected number of queue elements.

Other approach is to manage a (single or double) chained list of objects. See the Mosaic classes Core::TaskQueue and Core::Task as example of such implementation. In this case the class Core::Task implements the element of the queue. To manage the relation to the next/prev element as well as to the queue itself this class contains following variables:

The class Core::TaskQueue contains following two variables to manage the begin/end of the queue (to refer the first and the last element):

The method ScheduleTask() implements code to add new element to the queue. Here an example:

aTask.prev = last;

if ( last != null )
  last.next = aTask;
else
  first = aTask;

last = aTask;

The method CancelTask() implements code to remove an element from the queue. Here an example:

if ( aTask.next != null )
  aTask.next.prev = aTask.prev;
else
  last = aTask.prev;

if ( aTask.prev != null )
  aTask.prev.next = aTask.next
else
  first = aTask.next;

aTask.prev  = null;
aTask.next  = null;

I hope  with this information it is not too difficult to implement your own queue.

Best regards

Paul Banach

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...