本文整理汇总了C++中Poll函数的典型用法代码示例。如果您正苦于以下问题:C++ Poll函数的具体用法?C++ Poll怎么用?C++ Poll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Poll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void Sted::Handle (Event& e) {
if (e.eventType == KeyEvent) {
if (e.len != 0) {
char c = e.keystring[0];
switch (c) {
case '\010':
case '\177':
if (editor->Dot() != editor->Mark()) {
editor->DeleteSelection();
} else {
editor->DeleteText(-1);
}
break;
case '\015':
InsertChar('\n');
break;
default:
if (!iscntrl(c)) {
InsertChar(c);
}
break;
}
}
} else if (e.eventType == DownEvent) {
GetRelative(e.x, e.y, editor);
editor->Select(editor->Locate(e.x, e.y));
do {
editor->ScrollToView(e.x, e.y);
editor->SelectMore(editor->Locate(e.x, e.y));
Poll(e);
GetRelative(e.x, e.y, editor);
} while (e.leftmouse);
}
}
示例2: Poll
/// <summary>
/// Is laptop ?
/// </summary>
/// <returns></returns>
BOOL PowerSchemes::IsLaptop()
{
BOOL bLaptop = FALSE;
Poll();
if(isPsValid)
{
// BatteryFlag
//
// The battery charge status. This member can contain one or more of the following flags.
// 1: High¡ªthe battery capacity is at more than 66 percent
// 2: Low¡ªthe battery capacity is at less than 33 percent
// 4: Critical¡ªthe battery capacity is at less than five percent
// 8: Charging
// 128: No system battery
// 255: Unknown status¡ªunable to read the battery flag information
int BatStat = (int)pwrStat.BatteryFlag;
if (BatStat == 128)
{
bLaptop = FALSE;
}
else
{
bLaptop = TRUE;
}
}
return bLaptop;
}
示例3: Init
bool SocketImpl::Connect(const SocketAddress& address, const std::chrono::seconds& timeout /*= std::chrono::seconds(0)*/)
{
if (INVALID_SOCKET == m_sockfd)
Init(AF_INET);
if (timeout.count() > 0)
SetBlocking(false);
bool bResult = false;
do
{
if (SOCKET_ERROR == connect(m_sockfd, address.GetAddress(), address.GetLength()))
{
if (timeout.count() == 0)
break;
int err = WSAGetLastError();
if (WSAEINPROGRESS != err
&& WSAEWOULDBLOCK != err
&& WSAEISCONN != err)
break;
if (!Poll(timeout, SELECT_READ | SELECT_WRITE | SELECT_ERROR))
break;
if (GetSocketError() != 0)
break;
}
bResult = true;
} while (0);
if (timeout.count() > 0)
SetBlocking(true);
return bResult;
}
示例4: qWarning
void LongPollManager::handleGotLPServer()
{
auto reply = qobject_cast<QNetworkReply*> (sender ());
reply->deleteLater ();
if (reply->error () != QNetworkReply::NoError)
{
qWarning () << Q_FUNC_INFO
<< "error getting poll server:"
<< reply->errorString ();
QTimer::singleShot (15000,
this,
SLOT (start ()));
return;
}
const auto& data = QJson::Parser ().parse (reply);
const auto& map = data.toMap () ["response"].toMap ();
LPKey_ = map ["key"].toString ();
LPServer_ = map ["server"].toString ();
LPTS_ = map ["ts"].toULongLong ();
LPURLTemplate_ = QUrl ("http://" + LPServer_);
LPURLTemplate_.addQueryItem ("act", "a_check");
LPURLTemplate_.addQueryItem ("key", LPKey_);
LPURLTemplate_.addQueryItem ("mode", "2");
emit listening ();
Poll ();
}
示例5: _clean_fd
/* _clean_fd
* - Remove any extraneous packets sitting on the fd buffer
*/
static void
_clean_fd(int fd)
{
int rv;
struct pollfd ufds;
char buffer[IPMIPOWER_PACKET_BUFLEN];
while (1)
{
ufds.fd = fd;
ufds.events = POLLIN;
ufds.revents = 0;
/* Must use Poll, we may go outside of the fd numbers
* that Select is capable of using
*/
Poll(&ufds, 1, 0);
if (ufds.revents & POLLIN)
{
rv = Recvfrom(fd, (uint8_t *)buffer, IPMIPOWER_PACKET_BUFLEN, 0, NULL, NULL);
if (rv == 0)
break;
}
else
break;
ierr_dbg("_clean_fd: removed packet: %d", rv);
}
}
示例6: void
void Thread::addPollFd(int fd, int action, void (*handler)(void*, void*), void* p, void* q)
{
if (fd == -1)
return;
for (iPoll i = plist.begin(); i != plist.end(); ++i)
{
if ((i->fd == fd) && (i->action == action))
return;
}
plist.push_back(Poll(fd, action, handler, p, q));
if (npfd == maxpfd)
{
int n = (maxpfd == 0) ? 4 : maxpfd * 2;
//TODO: delete old pfd
pfd = new struct pollfd[n];
maxpfd = n;
}
++npfd;
int idx = 0;
for (iPoll i = plist.begin(); i != plist.end(); ++i, ++idx)
{
pfd[idx].fd = i->fd;
pfd[idx].events = i->action;
}
}
示例7: UpdateEvents
bool EventFsm::Update()
{
UpdateEvents();
Poll();
return true;
}
示例8: if
boolean StringBrowser::LeftButtonDown (Event& e) {
boolean status = false;
if (DoubleClicked(e)) {
subject->SetValue(done[0]);
status = true;
} else if (uniqueSel) {
if (Selections() == 0) {
Select(Locate(e.x, e.y));
} else {
Unselect(Selection());
if (!e.shift) {
Select(Locate(e.x, e.y));
}
}
} else {
lastdot = lastmark = Locate(e.x, e.y);
if (Selected(lastdot) && e.shift) {
Unselect(lastdot);
do {
ScrollToView(e.x, e.y);
UpdateSelection(lastdot, Locate(e.x, e.y), Plain);
Poll(e);
} while (e.leftmouse);
} else {
if (!e.shift) {
UnselectAll();
}
Select(lastdot);
do {
ScrollToView(e.x, e.y);
UpdateSelection(lastdot, Locate(e.x, e.y), highlight);
Poll(e);
} while (e.leftmouse);
}
}
Note(e);
if (singleClick) {
subject->SetValue(done[0]);
status = true;
}
return status;
}
示例9: Poll
void EEPROM::SetAddr(int addr)
{
//Sets EEPROM internal address pointer.
Poll(); //Poll until EEPROM acknowledges
SendByte(addr >> 8); //Send address high byte
SendByte(addr); //Send address low byte
}
示例10: while
void LuaHostWindows::WaitForDebuggerConnection()
{
while (!IsConnected())
{
Poll();
OsSleep(50);
}
}
示例11: Poke
void LightGun::Poke(const uint data)
{
if (arcade)
{
shifter = ~data & 0x1;
stream = (Poll() >= LIGHT_SENSOR ? 0x40 : 0x00);
stream |= 0x10 | fire;
}
}
示例12: Poll
void FamilyTrainer::Poke(const uint data)
{
if (input)
Poll();
if ((data & 0x1) == 0)
{
output = state >> 8 & 0x1E;
}
示例13: Poll
/*bool RegionFilteredSensor::projectSensorToBody(){
std::vector <position> vertices;
sbody->getGeometryVertices(&vertices);
}
*/
void BodySensor::outputSensorReadings(QTextStream & qts){
SensorOutput * so = Poll();
int sNum = SensorOutputTools::getSensorReadingNumber(so);
qts << "Body ";
for(int sInd = 0; sInd < sNum; sInd ++){
qts << " ";
qts << so->sensorReading[sInd];
}
qts << endl;
}
示例14: Poll
void FieldStringEditor::do_grab_scroll(Event& e) {
Window* w = canvas->window();
Cursor* c = w->cursor();
w->cursor(kit_->hand_cursor());
int origin = display->Left(0, 0);
int width = display->Width();
Poll(e);
int x = e.x;
do {
origin += e.x - x;
origin = Math::min(
0, Math::max(Math::min(0, xmax - width), origin)
);
display->Scroll(0, origin, ymax);
x = e.x;
Poll(e);
} while (e.middlemouse);
w->cursor(c);
}
示例15: m_pGameApp
Burger::Mouse::Mouse(GameApp *pGameApp) :
m_pGameApp(pGameApp),
m_MouseLock(),
m_pHIDManager(NULL),
m_uMiceCount(0),
m_uX(0),
m_uY(0),
m_uBoundsX(640),
m_uBoundsY(480),
m_iDeltaX(0),
m_iDeltaY(0),
m_iMouseWheelX(0),
m_iMouseWheelY(0),
m_uButtons(0),
m_uPressedButtons(0),
m_bButtonSwap(FALSE),
m_uArrayStart(0),
m_uArrayEnd(0)
{
// Back link to the game app
CFMutableDictionaryRef pDictionary = Globals::CreateHIDDictionary(kHIDPage_GenericDesktop,kHIDUsage_GD_Mouse);
if (pDictionary != NULL) {
m_pHIDManager = IOHIDManagerCreate(kCFAllocatorDefault,kIOHIDOptionsTypeNone);
if (m_pHIDManager != NULL) {
CFRunLoopRef pRunLoop = CFRunLoopGetCurrent();
IOHIDManagerRegisterDeviceMatchingCallback(m_pHIDManager,EnumerationCallback,this);
IOHIDManagerScheduleWithRunLoop(m_pHIDManager,pRunLoop,g_BurgerMouse);
IOHIDManagerSetDeviceMatching(m_pHIDManager,pDictionary);
IOHIDManagerOpen(m_pHIDManager,kIOHIDOptionsTypeNone);
// Handle the run loops
Poll(this);
// All scanned!
IOHIDManagerUnscheduleFromRunLoop(m_pHIDManager,pRunLoop,g_BurgerMouse);
IOHIDManagerRegisterDeviceMatchingCallback(m_pHIDManager,NULL, NULL);
// Open all the located devices
Word i;
DeviceStruct *pRat = m_Mice;
for (i = 0; i < m_uMiceCount; i++) {
IOHIDDeviceRef pDevice = pRat->m_pDevice;
if (IOHIDDeviceOpen(pDevice,kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
pRat->m_pDevice = NULL; // Hmm. Toast it
pRat->m_bUnplugged = FALSE; // Don't attempt to reconnect
} else {
IOHIDDeviceRegisterRemovalCallback(pDevice,DisconnectionCallback,this);
IOHIDDeviceRegisterInputValueCallback(pDevice,InputCallback,this);
IOHIDDeviceScheduleWithRunLoop(pDevice,pRunLoop,g_BurgerMouse);
}
++pRat;
}
pGameApp->AddRoutine(Poll,NULL,this,RunQueue::PRIORITY_MOUSE);
}
CFRelease(pDictionary);
}
}