• Main Page
  • Packages
  • Classes
  • Files
  • File List
  • File Members

unlock/bci/acquire-c++/NonblockingSignal.hpp

Go to the documentation of this file.
00001 
00002 // Copyright (c) James Percent and Unlock contributors.
00003 // All rights reserved.
00004 // Redistribution and use in source and binary forms, with or without modification,
00005 // are permitted provided that the following conditions are met:
00006 //
00007 //    1. Redistributions of source code must retain the above copyright notice,
00008 //       this list of conditions and the following disclaimer.
00009 //    
00010 //    2. Redistributions in binary form must reproduce the above copyright
00011 //       notice, this list of conditions and the following disclaimer in the
00012 //       documentation and/or other materials provided with the distribution.
00013 //
00014 //    3. Neither the name of Unlock nor the names of its contributors may be used
00015 //       to endorse or promote products derived from this software without
00016 //       specific prior written permission.
00017 
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00019 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00020 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00022 // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00024 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00025 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00027 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 
00029 #ifndef NONBLOCKING_SIGNAL_HPP
00030 #define NONBLOCKING_SIGNAL_HPP
00031 
00032 #include <boost/lockfree/spsc_queue.hpp>
00033 #include <boost/thread.hpp>
00034 #include <boost/atomic.hpp>
00035 
00036 #include "ISignal.hpp"
00037 #include "Sample.hpp"
00038 #include "SampleBuffer.hpp"
00039 #include "ManagedWorkController.hpp"
00040 #include "Portability.hpp"
00041 
00042 class DllExport NonblockingSignal : public ISignal
00043 {
00044  public: 
00045   static const size_t SAMPLE_BUFFER_SIZE=16384;
00046     
00047  public:
00048   NonblockingSignal(ISignal* pSignal);
00049   NonblockingSignal(const NonblockingSignal& copy);
00050   virtual ~NonblockingSignal();
00051   NonblockingSignal& operator=(const NonblockingSignal& other);
00052   
00053  public:
00054   virtual bool open(uint8_t*);
00055   virtual bool init(size_t);
00056   virtual size_t channels();
00057   virtual bool start();
00058   virtual size_t acquire();
00059   virtual void getdata(uint32_t* data, size_t n);
00060   virtual uint64_t timestamp();
00061   virtual bool stop();
00062   virtual bool close();
00063 
00064  private:
00065   void waitForAsyncCollector();
00066   
00067  private:
00068   ISignal* mpSignal;
00069   Sample<uint32_t>* mpProducerSamples;
00070   Sample<uint32_t>* mpConsumerSamples;
00071   SampleBuffer<uint32_t>* mpSampleRingBuffer;
00072   boost::lockfree::spsc_queue<Sample<uint32_t> >* mpQueue;
00073   boost::thread* mpAsyncSampleCollector;
00074   ManagedWorkController* mpWorkController;
00075 };
00076 
00077 #endif

Generated on Mon Nov 10 2014 11:09:08 for The Unlock Project by  doxygen 1.7.1