MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
actmsg.h
1//
2// actmsg.h
3//
4// based on: memamsg.h
5//
6// Copyright (C) 1996 Limit Point Systems, Inc.
7//
8// Author: Curtis Janssen <cljanss@limitpt.com>
9// Maintainer: LPS
10//
11// This file is part of the SC Toolkit.
12//
13// The SC Toolkit is free software; you can redistribute it and/or modify
14// it under the terms of the GNU Library General Public License as published by
15// the Free Software Foundation; either version 2, or (at your option)
16// any later version.
17//
18// The SC Toolkit is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU Library General Public License for more details.
22//
23// You should have received a copy of the GNU Library General Public License
24// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
25// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26//
27// The U.S. Government is granted a limited license as per AL 91-7.
28//
29
30#ifndef _util_group_actmsg_h
31#define _util_group_actmsg_h
32
33#include <iostream>
34
35#include <util/group/thread.h>
36#include <util/group/memmsg.h>
37#include <util/group/mstate.h>
38
39namespace sc {
40
41class ActiveMessageGrp;
42
46class ActiveMessage: virtual public SavableState {
47 public:
48 ActiveMessage() {}
53 virtual void run(int sender, int type, ActiveMessageGrp *context) = 0;
54};
55
59 int i_;
60 public:
62 ActiveMessageEcho(int i): i_(i) {}
64 void run(int sender, int type, ActiveMessageGrp *context);
65};
66
70 private:
71 ActiveMessageGrp *context_;
73 unsigned int nreq_recd_;
74 public:
76 ActiveMessageGrp *context);
77 void run();
78 int run_one();
79 unsigned int nreq_recd() { return nreq_recd_; }
80 void set_nreq_recd(unsigned int val) { nreq_recd_ = val; }
81};
82
88 protected:
89 int active_;
90 unsigned int *nreq_sent_;
91 ActiveMessageThread **thread_;
92
93 int statesend_type_;
94
95 Ref<MessageGrp> msg_;
96 Ref<ThreadGrp> thr_;
97
98 void init(const Ref<MessageGrp>& msg,
99 const Ref<ThreadGrp>& thr);
100
101 public:
107
111
115 void send(int node,
116 const Ref<StateSend> &,
117 const Ref<ActiveMessage> &);
118
121 void activate();
127 void sync();
128
130 Ref<MessageGrp> messagegrp() { return msg_; }
131
133 int n() const { return msg_->n(); }
135 int me() const { return msg_->me(); }
136};
137
138}
139
140#endif
141
142// Local Variables:
143// mode: c++
144// c-file-style: "CLJ"
145// End:
This is an ActiveMessage derivative used for testing.
Definition actmsg.h:58
void run(int sender, int type, ActiveMessageGrp *context)
This is called when ActiveMessageGrp is used to send an ActiveMessage object to a process.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
ActiveMessageGrp provides an implemention of active messages that sends objects derived from ActiveMe...
Definition actmsg.h:87
Ref< StateSend > get_statesend()
Each thread using the ActiveMessageGrp needs its own StateSend object.
ActiveMessageGrp(const Ref< MessageGrp > &msg, const Ref< ThreadGrp > &thr)
Construct an ActiveMessageGrp using a MessageGrp and a ThreadGrp.
void send(int node, const Ref< StateSend > &, const Ref< ActiveMessage > &)
Send the active message to node.
void activate()
Make the object ready to process messages.
void deactivate()
Processes all outstanding messages and disable processing of messages.
Ref< MessageGrp > messagegrp()
Return the MessageGrp used to implement the ActiveMessageGrp.
Definition actmsg.h:130
int n() const
Return the number of processes.
Definition actmsg.h:133
void sync()
Synchronize all of the processes in this group.
ActiveMessageGrp(const Ref< KeyVal > &)
A KeyVal CTOR for ActiveMessageGrp.
int me() const
Return my process identifier, starting at zero.
Definition actmsg.h:135
This is a help class that is used by ActiveMessageGrp.
Definition actmsg.h:69
void run()
This is called with the Thread is run from a ThreadGrp.
Derivatives of ActiveMessage can be constructed in one process and executed in another by using Activ...
Definition actmsg.h:46
virtual void run(int sender, int type, ActiveMessageGrp *context)=0
This is called when ActiveMessageGrp is used to send an ActiveMessage object to a process.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition actmsg.h:50
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition class.h:233
A template class that maintains references counts.
Definition ref.h:361
Base class for objects that can save/restore state.
Definition state.h:45
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Serializes fundamental and user-defined types.
Definition stateout.h:71
The Thread abstract class defines an interface which must be implemented by classes wishing to be run...
Definition thread.h:75
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.