25 #define OSVR_DEV_VERBOSE_DISABLE 
   39 namespace connection {
 
   40     using boost::unique_lock;
 
   43     AsyncDeviceToken::AsyncDeviceToken(std::string 
const &name)
 
   46     AsyncDeviceToken::~AsyncDeviceToken() {
 
   47         OSVR_DEV_VERBOSE(
"AsyncDeviceToken\t" 
   48                          "In ~AsyncDeviceToken");
 
   50         signalAndWaitForShutdown();
 
   53     void AsyncDeviceToken::signalShutdown() {
 
   54         OSVR_DEV_VERBOSE(
"AsyncDeviceToken\t" 
   56         m_run.signalShutdown();
 
   60     void AsyncDeviceToken::signalAndWaitForShutdown() {
 
   61         OSVR_DEV_VERBOSE(
"AsyncDeviceToken\t" 
   62                          "In signalAndWaitForShutdown");
 
   64         if (m_callbackThread) {
 
   65             m_run.signalAndWaitForShutdown();
 
   66             m_callbackThread->join();
 
   73         class WaitCallbackLoop {
 
   75             WaitCallbackLoop(::util::RunLoopManagerBase &run,
 
   76                              DeviceUpdateCallback 
const &cb)
 
   77                 : m_cb(cb), m_run(&run) {}
 
   79                 OSVR_DEV_VERBOSE(
"WaitCallbackLoop starting");
 
   80                 ::util::LoopGuard guard(*m_run);
 
   81                 while (m_run->shouldContinue()) {
 
   84                 OSVR_DEV_VERBOSE(
"WaitCallbackLoop exiting");
 
   88             DeviceUpdateCallback m_cb;
 
   89             ::util::RunLoopManagerBase *m_run;
 
   93     void AsyncDeviceToken::m_setUpdateCallback(DeviceUpdateCallback 
const &cb) {
 
   97     void AsyncDeviceToken::m_ensureThreadStarted() {
 
   98         if ((!m_callbackThread) && m_cb) {
 
   99             m_callbackThread.reset(
 
  100                 new boost::thread(WaitCallbackLoop(m_run, m_cb)));
 
  101             m_run.signalAndWaitForStart();
 
  106                                       MessageType *type, 
const char *bytestream,
 
  108         OSVR_DEV_VERBOSE(
"AsyncDeviceToken::m_sendData\t" 
  109                          "about to create RTS object");
 
  110         RequestToSend rts(m_accessControl);
 
  112         bool clear = rts.request();
 
  114             OSVR_DEV_VERBOSE(
"AsyncDeviceToken::m_sendData\t" 
  115                              "RTS request responded with not clear to send.");
 
  119         OSVR_DEV_VERBOSE(
"AsyncDeviceToken::m_sendData\t" 
  121         m_getConnectionDevice()->sendData(timestamp, type, bytestream, len);
 
  122         OSVR_DEV_VERBOSE(
"AsyncDeviceToken::m_sendData\t" 
  136     util::GuardPtr AsyncDeviceToken::m_getSendGuard() {
 
  137         util::GuardPtr ret(
new AsyncSendGuard(m_accessControl));
 
  141     void AsyncDeviceToken::m_connectionInteract() {
 
  142         m_ensureThreadStarted();
 
  143         OSVR_DEV_VERBOSE(
"AsyncDeviceToken::m_connectionInteract\t" 
  144                          "Going to send a CTS if waiting");
 
  145         bool handled = m_accessControl.mainThreadCTS();
 
  147             OSVR_DEV_VERBOSE(
"AsyncDeviceToken::m_connectionInteract\t" 
  150             OSVR_DEV_VERBOSE(
"AsyncDeviceToken::m_connectionInteract\t" 
  155     void AsyncDeviceToken::m_stopThreads() { signalAndWaitForShutdown(); }
 
A DeviceToken connects the generic device interaction code in PluginKit's C API with the workings of ...
An interface to a (deferred) guard class: after instantiation and lock returning true, some resource is locked and available until destruction. 
bool mainThreadDenyPermanently()
Permanently deny present and future requests. 
::OSVR_TimeValue TimeValue
C++-friendly typedef for the OSVR_TimeValue structure. 
Internal class handling the synchronization of an asynchronous thread wishing to communicate that has...
bool request()
Issues a blocking request to send. 
Internal, configured header file for verbosity macros. 
virtual bool lock()
Attempts to lock/request the resource, and returns true if successful.