When to call noteAbContentAvailable()?

Asked by joe on 2016-08-04

wat is the best to control this noteAbContentAvailable() from the adapter sample you have if (!buffer.empty())
to trigger the noteAbContentAvailable what will happen if we take of -->if (!buffer.empty()) is it safe or ??
what about using if (receivingVb == opOn) instead

void Adapter::Xaction::abMake()
{
 Must(sendingAb == opUndecided); // have not yet started or decided not to send
 Must(hostx->virgin().body()); // that is our only source of ab content

 // we are or were receiving vb
 Must(receivingVb == opOn || receivingVb == opComplete);

 sendingAb = opOn;
 if (!buffer.empty())
  hostx->noteAbContentAvailable();
}

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
joe
Solved:
2016-08-05
Last query:
2016-08-05
Last reply:
2016-08-04
Alex Rousskov (rousskov) said : #1

Your adapter transaction should call noteAbContentAvailable() when and only when both of the following two conditions become true:

1. the host application wants the adapter transaction to provide adapted body bytes
2. the adapter transaction is ready to provide adapted body bytes [that the host application was not informed about before]

In the sample code you pasted, condition #1 is satisfied by being inside the abMake() call, while condition #2 is determined by testing whether the buffer is empty.

joe (joejoe) said : #2

so receivingVb == opOn == notify the code there is data can be received right
 and receivingVb == opComplete == finish resiving so can get more
in this case both i can use for detection to call hostx->noteAbContentAvailable(); ??

Alex Rousskov (rousskov) said : #3

> receivingVb == opOn == notify the code there is data can be received right

In the modifying adapter sample, when receivingVb value is opOn, the adapter is expecting noteVb*() calls.

> and receivingVb == opComplete == finish resiving so can get more

When receivingVb value is opComplete, the adapter is not expecting more noteVb*() calls (but was expecting them at some time in the past).

You can find answers to questions like that by searching for "receivingVb = " expressions in the sample sources.

> both i can use for detection to call hostx->noteAbContentAvailable(); ??

I doubt it is a good idea to use [changes in] receivingVb state as the primary condition for calling noteAbContentAvailable(). You should call noteAbContentAvailable() when the two conditions I listed in my earlier answer become true. The changes in receivingVb state do not directly change or influence those two conditions AFAICT.

You might be trying to find a well-defined sequence of steps to receive and then send a body. There is no such sequence. Instead, there is a process/activity of receiving a virgin body and another process/activity of sending an adapted body. The two can be related, but it often helps to think of them as separate/independent processes/activities [with a couple of synchronization points in most cases].

joe (joejoe) said : #4

tks alex