Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / MT_BiDir / Sender_i.cpp
blob262880457aa44cf5c20ae00c0b36882664231fff
1 #include "Sender_i.h"
2 #include "ace/Manual_Event.h"
4 Sender_i::Sender_i (CORBA::ULong no_clients,
5 ACE_Manual_Event &event)
6 : event_ (event)
7 , receivers_ (0)
8 , no_clients_ (no_clients)
9 , last_index_ (0)
10 , payload_ (32768)
12 ACE_NEW (this->receivers_,
13 Receiver_var [no_clients]);
15 // Okay to have a magic number...
16 this->payload_.length (32768);
18 for (CORBA::ULong j = 0; j != this->payload_.length (); ++j)
19 this->payload_[j] = (j % 256);
22 Sender_i::~Sender_i ()
24 delete []this->receivers_;
27 CORBA::Long
28 Sender_i::receiver_object (Receiver_ptr recv)
30 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
31 ace_mon,
32 this->mutex_,-1);
34 if (this->no_clients_ == this->last_index_)
35 throw Sender::Table_Full ();
37 this->receivers_[this->last_index_] =
38 Receiver::_duplicate (recv);
40 ++this->last_index_;
42 if (this->last_index_ == this->no_clients_)
44 this->event_.signal ();
47 return this->last_index_;
51 void
52 Sender_i::send_message ()
54 // NOTE:No synchronization with purpose. Synchrnozing this is
55 // going to spoil the whole purpose of this test.
56 CORBA::ULong send_to =
57 static_cast<CORBA::ULong> (ACE_OS::rand () % this->no_clients_);
59 this->receivers_[send_to]->receive_payload (this->payload_);