Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
GcmTaskService: cancelling and scheduling a tag for a task which is currently processing

With GcmNetworkManager, my understanding is two tasks with same tag can never run concurrently. This is according to documentation here

Per service, two tasks with the same tag will never execute concurrently. Should a newly-scheduled task arrive while an existing task is still running, the new task will be dropped. In addition, different tasks may be scheduled concurrently, each invoked in a separate thread, if their schedules overlap. It is up to you to ensure thread safety when scheduling multiple tasks.

My question is:

If we schedule a task (a OneoffTask):

Task myTask = ... ;// create task of MY_TAG
gcmNetworkManager.schedule(myTask);

Then at some point later on we cancel it but let's assume it's currently running (its GcmTaskService:onRunTask is still running on its thread):

// Cancel task
// At this point GcmTaskService:onServiceRun could still be running (on a different thread)! 
// `GcmTaskService:onRunTask` will continue to run
gcmNetworkManager.cancelTask(MY_TAG, ..);

and then at another time later on, we re-schedule same tag:

// Re-schedule task. 
// At this point GcmTaskService:onRunTask could still be running (on a different thread)! 
Task myTask = ... ;// create task of MY_TAG
gcmNetworkManager.schedule(myTask);

when time comes to run GcmTaskService:onRunTask for the re-scheduled task, does GcmNetworkManager still knows there is a task running (GcmTaskService::onRunTask() hasn't returned? (Note that at this point its tag was cancelled)

Or does it actually starts a new GcmTaskService and callGcmTakService:onRunTask because its tag was cancelled? Which means there could actually be two GcmTaskService:onRunTask running at same time for same tag.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda