Code Search for Developers
 
 
  

lock.cpp from Equalizer - Multipipe Rendering at Krugle


Show lock.cpp syntax highlighted


#include <eq/base/lock.h>
#include <eq/base/thread.h>
#include <iostream>

using namespace eqBase;
using namespace std;

#define MAXTHREADS 256

volatile size_t nThreads;
Lock*           lock;

class Test : public Thread
{
public:
    virtual void* run()
        {
            lock->set();
            lock->unset();
            return EXIT_SUCCESS;
        }
};

int main( int argc, char **argv )
{
    lock = new Lock;
    lock->set();

    Test threads[MAXTHREADS];
    for( nThreads = MAXTHREADS; nThreads>1; nThreads = nThreads>>1 )
    {
        for( size_t i=0; i<nThreads; i++ )
            threads[i].start();

        lock->unset();

        for( size_t i=0; i<nThreads; i++ )
        {
            if( !threads[i].join( ))
            {
                cerr << "Could not join thread " << i << endl;
                exit(EXIT_FAILURE);
            }
        }
        lock->set();
    }

    delete lock;
    return EXIT_SUCCESS;
}





See more files for this project here

Equalizer - Multipipe Rendering

Equalizer is a programming interface and resource management system for scalable graphics applications for clusters and shared memory systems. It is build upon a scalable programming interface solving the problems common to any multipipe application.

Project homepage: http://sourceforge.net/projects/equalizer
Programming language(s): C,C++
License: lgpl21

  Makefile
  barrier.cpp
  idPool.cpp
  lock.cpp
  nodeID.cpp
  rng.cpp
  thread.cpp
  timedLock.cpp