[SERVER-6217] BackgroundJobs cannot be run multiple times Created: 27/Jun/12  Updated: 10/Dec/14  Resolved: 03/Jun/14

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Erich Siedler Assignee: Unassigned
Resolution: Done Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-7217 Provide a method for C++ driver clien... Closed
Operating System: ALL
Participants:

 Description   

Objects derived from BackgroundJob cannot be run more than once.

For example:

background_job.go();
background_job.wait();
background_job.go(); // throws

I'm submitting a pull request in github, with test cases and a patch.



 Comments   
Comment by Erich Siedler [ 27/Jun/12 ]

From background.h:

/**

  • Background thread dispatching.
  • subclass and define run()
    *
  • It is ok to call go(), that is, run the job, more than once – if the
  • previous invocation has finished. Thus one pattern of use is to embed
  • a backgroundjob in your object and reuse it (or same thing with
  • inheritance). Each go() call spawns a new thread.

I'm writing a Module ! and used this documented behaviour. (I intend to submit the module in the next days.)

Comment by Eliot Horowitz (Inactive) [ 27/Jun/12 ]

This is as designed.
Why do you want to add this?

Comment by Erich Siedler [ 27/Jun/12 ]

https://github.com/mongodb/mongo/pull/253

Generated at Thu Feb 08 03:11:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.