Qt 4.8
Classes | Macros | Functions | Variables
qeventdispatcher_blackberry.cpp File Reference
#include "qeventdispatcher_blackberry_p.h"
#include "qsocketnotifier.h"
#include "qdebug.h"
#include "qelapsedtimer.h"
#include "private/qthread_p.h"
#include <bps/bps.h>
#include <bps/event.h>

Go to the source code of this file.

Classes

class  BBScopedLoopLevelCounter
 
class  BpsChannelScopeSwitcher
 
struct  bpsIOHandlerData
 

Macros

#define qEventDispatcherDebug   QT_NO_QDEBUG_MACRO()
 

Functions

static int bpsIOHandler (int fd, int io_events, void *data)
 
static void destroyHeldBpsEvent (int holding_channel)
 
static int timevalToMillisecs (const timeval &tv)
 

Variables

static int bpsUnblockDomain = -1
 

Macro Definition Documentation

◆ qEventDispatcherDebug

#define qEventDispatcherDebug   QT_NO_QDEBUG_MACRO()

Function Documentation

◆ bpsIOHandler()

static int bpsIOHandler ( int  fd,
int  io_events,
void *  data 
)
static

Definition at line 108 of file qeventdispatcher_blackberry.cpp.

Referenced by QEventDispatcherBlackberry::registerSocketNotifier(), and QEventDispatcherBlackberry::unregisterSocketNotifier().

109 {
111  // decode callback payload
112  bpsIOHandlerData *ioData = static_cast<bpsIOHandlerData*>(data);
113 
114  // check if first file is ready
115  bool firstReady = (ioData->count == 0);
116 
117  // update ready state of file
118  if (io_events & BPS_IO_INPUT) {
119  qEventDispatcherDebug << fd << "ready for Read";
120  FD_SET(fd, ioData->readfds);
121  ioData->count++;
122  }
123 
124  if (io_events & BPS_IO_OUTPUT) {
125  qEventDispatcherDebug << fd << "ready for Write";
126  FD_SET(fd, ioData->writefds);
127  ioData->count++;
128  }
129 
130  if (io_events & BPS_IO_EXCEPT) {
131  qEventDispatcherDebug << fd << "ready for Exception";
132  FD_SET(fd, ioData->exceptfds);
133  ioData->count++;
134  }
135 
136  // force bps_get_event() to return immediately by posting an event to ourselves;
137  // but this only needs to happen once if multiple files become ready at the same time
138  if (firstReady) {
139  qEventDispatcherDebug << "Sending bpsIOReadyDomain event";
140  // create unblock event
141  bps_event_t *event;
142  int result = bps_event_create(&event, bpsUnblockDomain, 0, NULL, NULL);
143  if (Q_UNLIKELY(result != BPS_SUCCESS)) {
144  qWarning("QEventDispatcherBlackberry: bps_event_create failed");
145  return BPS_FAILURE;
146  }
147 
148  // post unblock event to our thread; in this callback the bps channel is
149  // guaranteed to be the same that was active when bps_add_fd was called
150  result = bps_push_event(event);
151  if (Q_UNLIKELY(result != BPS_SUCCESS)) {
152  qWarning("QEventDispatcherBlackberry: bps_push_event failed");
153  bps_event_destroy(event);
154  return BPS_FAILURE;
155  }
156  }
157 
158  return BPS_SUCCESS;
159 }
EventRef event
static int bpsUnblockDomain
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
#define qEventDispatcherDebug
#define Q_UNLIKELY(x)
Hints to the compiler that the enclosed condition, expr, is likely to evaluate to false...
Definition: qglobal.h:823
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ destroyHeldBpsEvent()

static void destroyHeldBpsEvent ( int  holding_channel)
inlinestatic

Definition at line 305 of file qeventdispatcher_blackberry.cpp.

Referenced by QEventDispatcherBlackberry::select().

306 {
307  // Switch to the holding channel and use bps_get_event() to trigger its destruction. We
308  // don't care about the return value from this call to bps_get_event().
309  BpsChannelScopeSwitcher holdingChannelSwitcher(holding_channel);
310  bps_event_t *held_event = 0;
311  (void)bps_get_event(&held_event, 0);
312  }

◆ timevalToMillisecs()

static int timevalToMillisecs ( const timeval &  tv)
inlinestatic

Definition at line 300 of file qeventdispatcher_blackberry.cpp.

Referenced by QEventDispatcherBlackberry::select().

301 {
302  return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
303 }

Variable Documentation

◆ bpsUnblockDomain

int bpsUnblockDomain = -1
static