Spinroot

A forum for Spin users

You are not logged in.

#1 2012-12-19 22:30:19

feng_lei_76
Member
Registered: 2011-05-13
Posts: 43

More Option of sending messages to a channel

Currently there are 3 different ways of sending messages to a channel.
1. If the queue is full, the sender is blocked; otherwise the channel is an FIFO queue.  For example chan ! x
2. If the queue is full, the sender is blocked; otherwise the channel is a sorted queue. For example chan !! x
3. If the queue is full, the sender is not blocked and the sent message is lost. With the option of -m for SPIN.

In addition to these, another option is necessary in implementation. 

If the queue is full, the sender is not blocked and the new message replaces the old one in the queue. 

This option is often preferred in systems transmitting data among processes. The most recent data are more important than the older ones.

In implementation, the semantics of this option is similar to a circular buffer data structure.

Offline

#2 2012-12-20 02:34:07

spinroot
forum
Registered: 2010-11-18
Posts: 694
Website

Re: More Option of sending messages to a channel

You can implement this functionality with a process, using an internal array to hold the messages, for instance. (Or by manipulating a standard channel inside that process that now acts as the channel.
You can also maple meant any other desired functionality in this way (e.g. Lossy channels).

Offline

Board footer

Powered by FluxBB