Example #1
0
unsigned __stdcall SecondThreadFunc( void* pArguments )
{
    printf( "In second thread...\n" );
	Future<int>* f = ( Future<int>* ) pArguments;
	std::cout << "In SecondThreadFunc " << f->Get() << std::endl;
    while ( Counter < 100000 )
        Counter++;
	CloseHandle( GetCurrentThread() );
    _endthreadex( 0 );
    return 0;
} 
Example #2
0
void USBDeviceManager::SignalEvent(EventType event, JaRuleWidget* widget) {
  if (!m_notification_cb.get()) {
    return;
  }

  if (pthread_equal(m_start_thread_id, Thread::Self())) {
    // We're within Start(), so we can execute the callbacks directly.
    m_notification_cb->Run(event, widget);
  } else {
    // We're not within Start(), which means we're running on the hotplug agent
    // thread. Schedule the callback to run and wait for it to complete.
    // By waiting we ensure the callback has completed before we go ahead and
    // delete the widget.
    Future<void> f;
    m_ss->Execute(NewSingleCallback(this, &USBDeviceManager::WidgetEvent,
                                    event, widget, &f));
    f.Get();
  }
}
void USBDeviceManager::SignalEvent(EventType event,
                                   JaRuleEndpoint* device,
                                   MutexLocker* locker) {
  // We hold the lock at this point.
  if (!m_notification_cb.get()) {
    return;
  }

  if (pthread_equal(m_start_thread_id, Thread::Self())) {
    locker->Release();
    // We're within Start(), so we can execute the callbacks directly.
    m_notification_cb->Run(event, device);
  } else {
    // We're not within Start(), which means we're running on the libusb event
    // thread. Schedule the callback to run and wait for it to complete.
    // By waiting we ensure the callback has completed before we go ahead and
    // delete the device.
    Future<void> f;
    m_ss->Execute(NewSingleCallback(this, &USBDeviceManager::DeviceEvent,
                                    event, device, &f));
    locker->Release();
    f.Get();
  }
}