Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Consume


Consume (channels: ChannelWithPeekFlag, continuation: C, persist: Boolean) (m: Match)->

  1. Fetch data residing on channels & look for match candidates
  2. If match:
    1. not found: store continuation with peek information
    2. found:
      1. return continuation
      2. For all match candidates: if not persist or not peek -> remove from tuplespace
    1. not found: store continuation with peek information
    2. found:

...


Produce


Produce(channel: C, data: A, persist: Boolean)(m: Match)

  1. Fetch joined channels Seq[Seq[C]] for channel
  2. Look for all matching waiting continuation under each sequence of channels
  3. If match:
    1. Not found: store data under channel
    2. Found:
      1. return data (from all channels) & continuation with peek information
      2. If not persist -> remove continuation
      For all matching data -> if channel is on the peek list or has persist flag set - do not remove. Else: remove from hot store
      1. For channel C -> if it has the peek flag in the continuation: do not store it and return the peek flag to the user
      2. For data matching on other channels -> if data is flagged with persit or peek -> don’t remove it. Otherwise do. Do not return the peek flag
  4. Not found: store data under channel
  5. Found:


Examples:

C - channel

K - continuation

as in trait ISpace[F[_], C, P, E, A, R, K] {

T[continuations][data]


A)

Tuplespace is empty. T[][]


Consume with channels = (C1, peek = true), continuation = K1, persist = false -> K1((C1, peek), !persist)

After matching:

T[K1((C1, peek),!persist)][]

Returned: none


B)

T[K1((C1, peek),!persist)][]


Produce (channel = C1(v1), persist = false)

T[][]

R: COMM(K1, C1(v1), peek)

Produce (channel = C1(v1), persist = false)

T[][C1(v1, !persist)]

R: empty


C)

T[K1((C1, peek),!persist)][]


Consume((C1, peek), K2, false)

T[K1((C1, peek),!persist), K2((C1, peek),!persist)][]

R: empty

Produce(C1(v2), false)

T[K1((C1, peek),!persist)][]

R: COMM(K2, C1(v2), peek)

Produce(C1(v2), !persist)

T[][]

R: COMM(K1, C1(v2), peek)

Produce(C1(v2), !persist)

T[][C1(v2, !persist)]

R: empty


D)

T[[K1((C1, peek),!persist), K2((C1, !peek)],!persist)][]


Produce (channel = C1(v1), persist = false)

2 possibilities:

1)

T[K2((C1, !peek)][]

R: COMM(K1, C1(v2), peek)

Produce (channel = C1(v1), persist = false)

T[][]

R: COMM(K2, C1(v2))

2)

T[K1((C1, peek),!persist)][]

R: COMM(K2, C1(v2))



E)

T[K1([(C1, peek), (C2, !peek)], !persist)][C2(v2, !persist)]


Produce (channel = C1(v1), persist = false)

T[][]

R: COMM(K1, C1(v1), C2(v2), peek)

Produce (channel = C1(v1), persist = false)

T[][C1(v1, !persist)]

R: empty


F)

T[K1([(C1, peek), (C2, peek)], !persist)][C2(v2, !persist)]


Produce (channel = C1(v1), persist = false)

T[][C2(v2, !persist)]

R: COMM(K1, C1(v1), C2(v2),peek)

Produce (channel = C1(v1), persist = false)

T[][C1(v1, !persist), C2(v2, !persist)]

R: empty