Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda