本文整理汇总了C++中InMainThread函数的典型用法代码示例。如果您正苦于以下问题:C++ InMainThread函数的具体用法?C++ InMainThread怎么用?C++ InMainThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InMainThread函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
DeviceDescriptor::Close()
{
assert(InMainThread());
assert(!IsBorrowed());
CancelAsync();
#ifdef HAVE_INTERNAL_GPS
delete internal_sensors;
internal_sensors = nullptr;
#endif
#ifdef ANDROID
delete droidsoar_v2;
droidsoar_v2 = nullptr;
for (unsigned i=0; i<sizeof i2cbaro/sizeof i2cbaro[0]; i++) {
delete i2cbaro[i];
i2cbaro[i] = nullptr;
}
delete nunchuck;
nunchuck = nullptr;
delete voltage;
voltage = nullptr;
#endif
/* safely delete the Device object */
Device *old_device = device;
{
const ScopeLock protect(mutex);
device = nullptr;
/* after leaving this scope, no other thread may use the old
object; to avoid locking the mutex for too long, the "delete"
is called after the scope */
}
delete old_device;
delete second_device;
second_device = nullptr;
Port *old_port = port;
port = nullptr;
delete old_port;
ticker = false;
{
const ScopeLock lock(device_blackboard->mutex);
device_blackboard->SetRealState(index).Reset();
device_blackboard->ScheduleMerge();
}
settings_sent.Clear();
settings_received.Clear();
}
示例2: ApplyVegaSwitches
void
ApplyVegaSwitches()
{
assert(InMainThread());
const VegaSwitchState &switches = CommonInterface::Basic().switch_state.vega;
// detect changes to ON: on now (x) and not on before (!lastx)
// detect changes to OFF: off now (!x) and on before (lastx)
const unsigned up_inputs = switches.inputs & ~last_vega_switches.inputs;
const unsigned down_inputs = ~switches.inputs & last_vega_switches.inputs;
const unsigned up_outputs = switches.outputs & ~last_vega_switches.outputs;
const unsigned down_outputs = ~switches.outputs & last_vega_switches.outputs;
last_vega_switches = switches;
for (unsigned i = 0; i < 32; ++i) {
const unsigned thebit = 1 << i;
if (down_inputs & thebit)
InputEvents::processNmea(i);
else if (up_inputs & thebit)
InputEvents::processNmea(i + 64);
if (down_outputs & thebit)
InputEvents::processNmea(i + 32);
else if (up_outputs & thebit)
InputEvents::processNmea(i + 96);
}
}
示例3: assert
void
InputEvents::DoQueuedEvents()
{
assert(InMainThread());
int GCE_Queue_copy[MAX_GCE_QUEUE];
int i;
// copy the queue first, blocking
{
const ScopeLock lock(mutexEventQueue);
std::copy_n(GCE_Queue, MAX_GCE_QUEUE, GCE_Queue_copy);
std::fill_n(GCE_Queue, MAX_GCE_QUEUE, -1);
}
// process each item in the queue
for (i = 0; i < MAX_GCE_QUEUE; i++) {
if (GCE_Queue_copy[i] != -1) {
processGlideComputer_real(GCE_Queue_copy[i]);
}
}
for (i = 0; i < MAX_NMEA_QUEUE; i++) {
if (NMEA_Queue[i] != -1)
processNmea_real(NMEA_Queue[i]);
}
}
示例4: EnterDrawThread
void
EnterDrawThread()
{
assert(InMainThread());
assert(draw_thread_handle == zero_thread_handle);
draw_thread_handle = ThreadHandle::GetCurrent();
}
示例5: LeaveDrawThread
void
LeaveDrawThread()
{
assert(InMainThread());
assert(draw_thread_handle.IsInside());
draw_thread_handle = zero_thread_handle;
}
示例6: InDrawThread
bool
InDrawThread()
{
#ifdef ENABLE_OPENGL
return InMainThread() && draw_thread_handle.IsInside();
#else
return draw_thread != nullptr && draw_thread->IsInside();
#endif
}
示例7: assert
bool
DeviceDescriptor::PutStandbyFrequency(RadioFrequency frequency,
OperationEnvironment &env)
{
assert(InMainThread());
if (device == NULL || !config.sync_to_device)
return true;
if (!Borrow())
/* TODO: postpone until the borrowed device has been returned */
return false;
ScopeReturnDevice restore(*this, env);
return device->PutStandbyFrequency(frequency, env);
}
示例8: assert
void
DeviceDescriptor::OnNotification()
{
/* notification from AsyncJobRunner, the Job was finished */
assert(InMainThread());
assert(open_job != nullptr);
try {
async.Wait();
} catch (const std::runtime_error &e) {
LogError(e);
}
delete open_job;
open_job = nullptr;
}
示例9: assert
void
DeviceDescriptor::Open(OperationEnvironment &env)
{
assert(InMainThread());
assert(port == nullptr);
assert(device == nullptr);
assert(!ticker);
assert(!IsBorrowed());
if (is_simulator() || !config.IsAvailable())
return;
CancelAsync();
assert(!IsOccupied());
assert(open_job == nullptr);
TCHAR buffer[64];
LogFormat(_T("Opening device %s"), config.GetPortName(buffer, 64));
open_job = new OpenDeviceJob(*this);
async.Start(open_job, env, this);
}
示例10: GetComputerSettings
/**
* Returns the InterfaceBlackboard.ComputerSettings (read-only)
* @return The InterfaceBlackboard.ComputerSettings
*/
gcc_const
static inline const ComputerSettings& GetComputerSettings() {
assert(InMainThread());
return Private::blackboard.GetComputerSettings();
}
示例11: InDrawThread
bool
InDrawThread()
{
return InMainThread();
}
示例12: assert
/**
* Returns InterfaceBlackboard.Basic (NMEA_INFO) (read-only)
* @return InterfaceBlackboard.Basic
*/
gcc_const
static inline const MoreData &Basic() {
assert(InMainThread());
return Private::blackboard.Basic();
}
示例13: CanBorrow
/**
* Can this device be borrowed?
*
* May only be called from the main thread.
*
* @see Borrow()
*/
bool CanBorrow() const {
assert(InMainThread());
return device != nullptr && GetState() == PortState::READY &&
!IsOccupied();
}
示例14: IsOccupied
/**
* Is this device currently occupied, i.e. does somebody have
* exclusive access?
*
* May only be called from the main thread.
*/
bool IsOccupied() const {
assert(InMainThread());
return IsBorrowed() || async.IsBusy();
}