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
feita há 5 anos268 visualizações
1 Resposta
0
Resposta aceita

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
respondido há 5 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas