Core Architecture  «Prev 

Simple Producer/Consumer Example

Assume we have a simple queue class:
template<class T> class Queue {
public:
void enqueue(const T & item);
T dequeue();
};

  1. Producer threads read items from somewhere and place them on the queue by calling enqueue.
  2. Consumer threads fetch items from the queue by calling dequeue.
  3. The queue is a critical region and the consumer threads must be suspended when the queue is empty.

#include <list > template<class T> class Queue { public: void enqueue(const T & item) { m_q.push_back(item); } T dequeue() { T item = m_q.front(); m_q.pop_front(); return item; } private: list<T> m_q; };
#include <list >
#include <JTC/JTC.h >
template<class T> class Queue : JTCMonitor {
 public:
  void enqueue(const T & item) {
   JTCSynchronized lock(*this);
   m_q.push_back(item);
   notify();
  }
  T dequeue() {
   JTCSynchronized lock(*this);
   while (m_q.size() == 0) {
    try {
     wait();
    } catch (const JTCInterruptedException & ) {
   }
  }
  T item = m_q.front();
  m_q.pop_front();
  return item;
 }
 private:
 list<T> m_q;
};

Corba Consumer

1) At the basic level, a CORBA Client simply wishes to obtain services from a Corba server
1) At the basic level, a CORBA Client simply wishes to obtain services from a Corba server.

2) The CORBA Stub does most of the work, so the client may remain simple.
2) The CORBA Stub does most of the work, so the client may remain simple.

3) We have already started to explore the CORBA development proces, this illustrates the rest of the process for clients.
3) We have already started to explore the CORBA development proces, this illustrates the rest of the process for clients.

Corba Fundamentals
4) The CORBA architect creates an IDL file, the Stub is produced when the IDL is run through an ORB vendors IDL pre-processor
4) The CORBA architect creates an IDL file, the Stub is produced when the IDL is run through an ORB vendors IDL pre-processor, and the CORBA client uses the Stub to write and compile the client. The files that must be written by developers are highlighted in yellow.