NAME
ACE_Process_Manager -
Manages a pool of processs.
SYNOPSIS
#include <ace/Process_Manager.h >
class ACE_Process_Manager
{
public:
friend class ACE_Process_Control;
enum{ DEFAULT_SIZE = 100 };
ACE_Process_Manager (
size_t size = ACE_Process_Manager::DEFAULT_SIZE
);
~ACE_Process_Manager (void);
int open (size_t size = DEFAULT_SIZE);
int close (void);
int spawn (
ACE_THR_FUNC func,
void *args,
long flags,
pid_t * = 0,
u_int priority = 0,
void *stack = 0,
size_t stack_size = 0
);
int spawn_n (
int n,
ACE_THR_FUNC func,
void *args,
long flags,
u_int priority = 0
);
void *exit (void *status);
int wait (ACE_Time_Value *timeout = 0);
int suspend_all (void);
int suspend (pid_t);
int suspend_grp (int grp_id);
int resume_all (void);
int resume (pid_t);
int resume_grp (int grp_id);
int kill_all (int signum);
int kill (pid_t, int signum);
int kill_grp (int grp_id, int signum);
int set_grp (pid_t, int grp_id);
int get_grp (pid_t, int &grp_id);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
int resize (size_t);
int spawn_i (
ACE_THR_FUNC func,
void *args,
long flags,
pid_t * = 0,
u_int priority = 0,
void *stack = 0,
size_t stack_size = 0
);
int find (pid_t p_id);
int insert_proc (pid_t p_id);
int append_proc (
pid_t p_id,
ACE_Process_Descriptor::Process_State
);
void remove_proc (int i);
typedef int (ACE_Process_Manager::*PROC_FUNC)(int, int);
int apply_grp (int grp_id, PROC_FUNC, int = 0);
int apply_all (PROC_FUNC, int = 0);
int resume_proc (int i);
int suspend_proc (int i);
int kill_proc (int i, int signum);
ACE_Process_Descriptor *proc_table_;
size_t max_table_size_;
size_t current_count_;
int grp_id_;
};
DESCRIPTION
This class allows operations on groups of processs atomically.
Initialization and termination methods.
ACE_Process_Manager (size_t size = ACE_Process_Manager::DEFAULT_SIZE);
~ACE_Process_Manager (void);
int open (size_t size = DEFAULT_SIZE);
Initialize the manager with room for SIZE processs.
int close (void);
int spawn (
ACE_THR_FUNC func,
void *args,
long flags,
pid_t * = 0,
u_int priority = 0,
void *stack = 0,
size_t stack_size = 0
);
Create a new process, which executes func.
Returns: on success a unique group id that can be used to control
other processs added to the same group. On failure, returns -1.
int spawn_n (
int n,
ACE_THR_FUNC func,
void *args,
long flags,
u_int priority = 0
);
Create N new processs, all of which execute func.
Returns: on success a unique group id that can be used to control
all of the processs in the same group. On failure, returns -1.
void *exit (void *status);
Called to clean up when a process exits.
int wait (ACE_Time_Value *timeout = 0);
Block until there are no more processs running or timeout
expires. Returns 0 on success and -1 on failure.
Suspend methods.
int suspend_all (void);
int suspend (pid_t);
Suspend a single process.
int suspend_grp (int grp_id);
Suspend a group of processs.
Resume methods.
int resume_all (void);
Resume all stopped processs
int resume (pid_t);
int resume_grp (int grp_id);
Resume a group of processs.
Kill methods (send signals...).
int kill_all (int signum);
Send signum to all stopped processs
int kill (pid_t, int signum);
int kill_grp (int grp_id, int signum);
Kill a group of processs.
Set/get group ids for a particular process id.
int set_grp (pid_t, int grp_id);
int get_grp (pid_t, int &grp_id);
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
The following four methods implement a simple scheme for
operating on a collection of processs atomically.
typedef int (ACE_Process_Manager::*PROC_FUNC)(int, int);
int apply_grp (int grp_id, PROC_FUNC, int = 0);
Apply func to all members of the table that match the grp_id.
int apply_all (PROC_FUNC, int = 0);
Apply func to all members of the table.
int resume_proc (int i);
Resume the process at index i.
int suspend_proc (int i);
Suspend the process at index i.
int kill_proc (int i, int signum);
Send signal signum to the process at index i.
ACE_Process_Descriptor *proc_table_;
Vector that describes process state within the Process_Manager.
size_t max_table_size_;
Maximum number of processs we can manage (should be dynamically
allocated).
size_t current_count_;
Current number of processs we are managing.
int grp_id_;
Keeps track of the next group id to assign.
AUTHOR
Doug Schmidt
LIBRARY
ace