struct poll_handler {
int fd;
- uv_poll_t *uv_poll;
+ uv_poll_t* uv_poll;
int eventmask;
int ref;
std::list<GPollFD*> fd_list;
};
-GContext::GContext():initialized_(false) {
+GContext::GContext() :
+ initialized_(false),
+ context_(NULL),
+ max_priority_(0),
+ fd_list_(NULL),
+ fd_list_size_(0),
+ fd_count_(0),
+ prepare_handle_(NULL),
+ check_handle_(NULL),
+ timeout_handle_(NULL) {
}
GContext::~GContext() {
if (initialized_)
return;
initialized_ = true;
- GMainContext *gc = g_main_context_default();
+ GMainContext* gc = g_main_context_default();
#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
g_main_context_unref(context_);
}
-static void poll_cb(uv_poll_t *uv_handle, int status, int events) {
+static void poll_cb(uv_poll_t* uv_handle, int status, int events) {
poll_handler* handle = static_cast<poll_handler*>(uv_handle->data);
if (status == 0) {
std::list<GPollFD*>::iterator itr = handle->fd_list.begin();
}
void GContext::onPrepare() {
- int i;
int timeout;
g_main_context_prepare(context_, &max_priority_);
handle->fd_list.clear();
// check already initialized poll handles
- for (i = 0; i < fd_count_; ++i) {
- GPollFD *pfd = fd_list_ + i;
+ for (int i = 0; i < fd_count_; ++i) {
+ GPollFD* pfd = fd_list_ + i;
if (handle->fd == pfd->fd) {
flagsTable.get()[i] = 1;
handle->ref++;
std::list<poll_handler*> new_poll_fds;
/* Process current file descriptors from GContext */
- for (i = 0; i < fd_count_; ++i) {
- GPollFD *pfd = &fd_list_[i];
+ for (int i = 0; i < fd_count_; ++i) {
+ GPollFD* pfd = &fd_list_[i];
int exists = flagsTable.get()[i];
if (exists)
continue;
pfd->revents = 0;
for (itr = new_poll_fds.begin(); itr != new_poll_fds.end(); ++itr) {
- poll_handler *handle = *itr;
+ poll_handler* handle = *itr;
if (handle->fd == pfd->fd) {
int oldmask = handle->eventmask;
handle->eventmask |= (pfd->events & G_IO_IN ? UV_READABLE: 0)
handle->ref = 1;
/* Create uv poll handler, then append own poll handler on it */
- uv_poll_t *pt = static_cast<uv_poll_t*>(malloc(sizeof(uv_poll_t)));
+ uv_poll_t* pt = static_cast<uv_poll_t*>(malloc(sizeof(uv_poll_t)));
memset(pt, 0, sizeof(uv_poll_t));
pt->data = handle;
handle->uv_poll = pt;
void GContext::OnPrepare(uv_prepare_t* handle) {
- GContext *This = static_cast<GContext*>(handle->data);
+ GContext* This = static_cast<GContext*>(handle->data);
This->onPrepare();
}
}
-static GContext *g_context = NULL;
+static GContext* g_context = NULL;
static void GContextInit(const v8::FunctionCallbackInfo<v8::Value>&) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
static void OnTimeout(uv_timer_s* handle);
bool initialized_;
- GMainContext *context_;
+ GMainContext* context_;
int max_priority_;
- GPollFD *fd_list_;
+ GPollFD* fd_list_;
int fd_list_size_;
int fd_count_;
std::list<poll_handler*> poll_handle_list_;
- uv_prepare_t *prepare_handle_;
- uv_check_t *check_handle_;
- uv_timer_t *timeout_handle_;
+ uv_prepare_t* prepare_handle_;
+ uv_check_t* check_handle_;
+ uv_timer_t* timeout_handle_;
};
} // namespace service
LOGW("xw_extension (%d) is invalid.", xw_extension);
return;
}
- if (extension_map_.find(xw_extension) != extension_map_.end())
- extension_map_.erase(xw_extension);
+ extension_map_.erase(xw_extension);
}
void ExtensionAdapter::RegisterInstance(ExtensionInstance* instance) {
LOGW("xw_instance (%d) is invalid.", xw_instance);
return;
}
- if (instance_map_.find(xw_instance) != instance_map_.end())
- instance_map_.erase(xw_instance);
+ instance_map_.erase(xw_instance);
}
const void* ExtensionAdapter::GetInterface(const char* name) {