MPQC  3.0.0-alpha
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 
39 namespace sc {
40 
41 class ActiveMessageGrp;
42 
46 class 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) {}
63  void save_data_state(StateOut &);
64  void run(int sender, int type, ActiveMessageGrp *context);
65 };
66 
69 class ActiveMessageThread: public Thread {
70  private:
71  ActiveMessageGrp *context_;
72  Ref<StateRecv> in_;
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:
103  ActiveMessageGrp(const Ref<MessageGrp>& msg, const Ref<ThreadGrp>& thr);
106  ~ActiveMessageGrp();
107 
111 
115  void send(int node,
116  const Ref<StateSend> &,
117  const Ref<ActiveMessage> &);
118 
121  void activate();
125  void deactivate();
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:
sc::ActiveMessage::save_data_state
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
sc::ActiveMessageGrp::me
int me() const
Return my process identifier, starting at zero.
Definition: actmsg.h:135
sc::ActiveMessageEcho::run
void run(int sender, int type, ActiveMessageGrp *context)
This is called when ActiveMessageGrp is used to send an ActiveMessage object to a process.
sc::ActiveMessageGrp::n
int n() const
Return the number of processes.
Definition: actmsg.h:133
sc::ActiveMessageGrp::get_statesend
Ref< StateSend > get_statesend()
Each thread using the ActiveMessageGrp needs its own StateSend object.
sc::ActiveMessageGrp::sync
void sync()
Synchronize all of the processes in this group.
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::ActiveMessageEcho::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::ActiveMessageEcho
This is an ActiveMessage derivative used for testing.
Definition: actmsg.h:58
sc::Thread
The Thread abstract class defines an interface which must be implemented by classes wishing to be run...
Definition: thread.h:75
sc::ActiveMessageGrp
ActiveMessageGrp provides an implemention of active messages that sends objects derived from ActiveMe...
Definition: actmsg.h:87
sc::ActiveMessage
Derivatives of ActiveMessage can be constructed in one process and executed in another by using Activ...
Definition: actmsg.h:46
sc::ActiveMessage::run
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.
sc::StateIn
Definition: statein.h:79
sc::ActiveMessageGrp::deactivate
void deactivate()
Processes all outstanding messages and disable processing of messages.
sc::ActiveMessageThread::run
void run()
This is called with the Thread is run from a ThreadGrp.
sc::StateOut
Definition: stateout.h:71
sc::ActiveMessageGrp::ActiveMessageGrp
ActiveMessageGrp(const Ref< MessageGrp > &msg, const Ref< ThreadGrp > &thr)
Construct an ActiveMessageGrp using a MessageGrp and a ThreadGrp.
sc::DescribedClass
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:233
sc::ActiveMessageGrp::send
void send(int node, const Ref< StateSend > &, const Ref< ActiveMessage > &)
Send the active message to node.
sc::ActiveMessageGrp::activate
void activate()
Make the object ready to process messages.
sc::SavableState
Base class for objects that can save/restore state.
Definition: state.h:45
sc::ActiveMessageThread
This is a help class that is used by ActiveMessageGrp.
Definition: actmsg.h:69
sc::ActiveMessageGrp::messagegrp
Ref< MessageGrp > messagegrp()
Return the MessageGrp used to implement the ActiveMessageGrp.
Definition: actmsg.h:130
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:24:01 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.