Waiting on dynamic list of promises

0

Hello,

I would like to wait on a list of promises, but the list is dynamically updated (items are added to) by a signal handler.
I tried two approaches - @Wait in the function and waiting on AndPromise. In case of AndPromise - it is a member variable of WF class and gets recreated when a new promise is added to the list by signal handler.

In both cases the function starts execution as soon as the first promise in the list is ready.

How to fix it?

Alex2
demandé il y a 5 ans268 vues
1 réponse
0
Réponse acceptée

Would you clarify your requirements? It looks like that you want to invoke some activity on the first signal and if no new signal is received after the activity is completed just exit the workflow. But if new signals are received while executing the activity then execute them. Correct?

I would just have a queue as a field of the workflow. Then the workflow would read from that queue in a loop (it has to use recursion due to async nature of the code) and exit if it is empty. Then you need another Promise that the workflow function waits on at the beginning until the first signal is received.
In this design you never wait for more than a single Promise at a time.

mfateev
répondu il y a 5 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions