7127792: Add the ability to change an existing PeriodicTask's execution interval

Enables dynamic enrollment / disenrollment from the PeriodicTasks in WatcherThread.

Reviewed-by: dholmes, mgronlun
This commit is contained in:
Rickard Bäckman 2012-10-04 14:55:57 +02:00
parent 61a5a58cb1
commit e1d995ab86
6 changed files with 162 additions and 92 deletions

View file

@ -722,6 +722,7 @@ class WatcherThread: public Thread {
private:
static WatcherThread* _watcher_thread;
static bool _startable;
volatile static bool _should_terminate; // updated without holding lock
public:
enum SomeConstants {
@ -738,6 +739,7 @@ class WatcherThread: public Thread {
char* name() const { return (char*)"VM Periodic Task Thread"; }
void print_on(outputStream* st) const;
void print() const { print_on(tty); }
void unpark();
// Returns the single instance of WatcherThread
static WatcherThread* watcher_thread() { return _watcher_thread; }
@ -745,6 +747,12 @@ class WatcherThread: public Thread {
// Create and start the single instance of WatcherThread, or stop it on shutdown
static void start();
static void stop();
// Only allow start once the VM is sufficiently initialized
// Otherwise the first task to enroll will trigger the start
static void make_startable();
private:
int sleep() const;
};