NAME

ACE_Task - Primary interface for application message processing, as well as input and output message queueing.

SYNOPSIS


#include <ace/Task.h>


template<ACE_SYNCH_1>
class ACE_Task : public ACE_Service_Object
{
  public:
    friend class ACE_Module<ACE_SYNCH_2>;
    friend class ACE_Module_Type;
    friend class ACE_Task_Exit<ACE_SYNCH_2>;
    ACE_Task (
        ACE_Thread_Manager *thr_mgr = 0,
        ACE_Message_Queue<ACE_SYNCH_2> *mq = 0
        );
    virtual int open (void *args = 0) = 0;
    virtual int close (u_long flags = 0) = 0;
    virtual ~ACE_Task (void);
    virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0) = 0;
    virtual int svc (void);
    virtual int activate (
        long flags = THR_NEW_LWP,
        int n_threads = 1,
        int force_active = 0,
        u_int priority = 0,
        int grp_id = -1
        );
    virtual int suspend (void);
    virtual int resume (void);
    int grp_id (void);
    void grp_id (int);
    ACE_Thread_Manager *thr_mgr (void);
    void thr_mgr (ACE_Thread_Manager *);
    ACE_Message_Queue<ACE_SYNCH_2> *msg_queue (void);
    void msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *);
    size_t thr_count (void);
    static void *svc_run (ACE_Task<ACE_SYNCH_2> *);
    int can_put (ACE_Message_Block *);
    int putq (ACE_Message_Block *, ACE_Time_Value *tv = 0);
    int getq (ACE_Message_Block *&mb, ACE_Time_Value *tv = 0);
    int ungetq (ACE_Message_Block *, ACE_Time_Value *tv = 0);
    int put_next (ACE_Message_Block *msg, ACE_Time_Value *tv = 0);
    int reply (ACE_Message_Block *, ACE_Time_Value *tv = 0);
    const char *name (void) const;
    ACE_Task<ACE_SYNCH_2> *sibling (void);
    ACE_Module<ACE_SYNCH_2> *module (void) const;
    int is_reader (void);
    int is_writer (void);
    ACE_Task<ACE_SYNCH_2> *next (void);
    void next (ACE_Task<ACE_SYNCH_2> *);
    int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL);
    void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t);
    void thr_count_dec (void);
    size_t thr_count_;
    ACE_Thread_Manager *thr_mgr_;
    ACE_Message_Queue<ACE_SYNCH_2> *msg_queue_;
    int delete_msg_queue_;
    u_long flags_;
    ACE_Module<ACE_SYNCH_2> *mod_;
    ACE_Task<ACE_SYNCH_2> *next_;
    int grp_id_;
    ACE_Thread_Mutex lock_;
    void dump (void) const;
    ACE_ALLOC_HOOK_DECLARE;
};

DESCRIPTION

This class serves as the basis for passive and active objects in ACE.

Initialization/termination methods.

ACE_Task (
    ACE_Thread_Manager *thr_mgr = 0,
    ACE_Message_Queue<ACE_SYNCH_2> *mq = 0
    );

Initialization and termination hooks (note that these *must* be

defined by subclasses).
virtual int open (void *args = 0) = 0;
virtual int close (u_long flags = 0) = 0;
virtual ~ACE_Task (void);

Immediate and deferred processing methods, respectively.

virtual int put (ACE_Message_Block *, ACE_Time_Value *tv = 0) = 0;
virtual int svc (void);

Active object activation method.

virtual int activate (
    long flags = THR_NEW_LWP,
    int n_threads = 1,
    int force_active = 0,
    u_int priority = 0,
    int grp_id = -1
    );

Suspend/resume a Task

virtual int suspend (void);
virtual int resume (void);
int grp_id (void);
void grp_id (int);
ACE_Thread_Manager *thr_mgr (void);
void thr_mgr (ACE_Thread_Manager *);
ACE_Message_Queue<ACE_SYNCH_2> *msg_queue (void);
void msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *);
size_t thr_count (void);
static void *svc_run (ACE_Task<ACE_SYNCH_2> *);

Message queue manipulation methods.

int can_put (ACE_Message_Block *);
int putq (ACE_Message_Block *, ACE_Time_Value *tv = 0);
int getq (ACE_Message_Block *&mb, ACE_Time_Value *tv = 0);
int ungetq (ACE_Message_Block *, ACE_Time_Value *tv = 0);
int put_next (ACE_Message_Block *msg, ACE_Time_Value *tv = 0);
int reply (ACE_Message_Block *, ACE_Time_Value *tv = 0);

ACE_Task utility routines to identify names et al.

const char *name (void) const;
ACE_Task<ACE_SYNCH_2> *sibling (void);
ACE_Module<ACE_SYNCH_2> *module (void) const;
int is_reader (void);
int is_writer (void);

Pointers to next ACE_Queue (if ACE is part of an ACE_Stream).

ACE_Task<ACE_SYNCH_2> *next (void);
void next (ACE_Task<ACE_SYNCH_2> *);
int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL);
void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t);
void thr_count_dec (void);

Internal data (should be private...).

private:
size_t thr_count_;
ACE_Thread_Manager *thr_mgr_;
ACE_Message_Queue<ACE_SYNCH_2> *msg_queue_;
int delete_msg_queue_;
u_long flags_;
ACE_Module<ACE_SYNCH_2> *mod_;
ACE_Task<ACE_SYNCH_2> *next_;
int grp_id_;
ACE_Thread_Mutex lock_;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;

AUTHOR

Doug Schmidt

LIBRARY

ace