Ejemplo n.º 1
0
/*----------------------------------------------------------------------------*/
int 
mtcp_epoll_create(mctx_t mctx, int size)
{
	mtcp_manager_t mtcp = g_mtcp[mctx->cpu];
	struct mtcp_epoll *ep;
	socket_map_t epsocket;

	if (size <= 0) {
		errno = EINVAL;
		return -1;
	}

	epsocket = AllocateSocket(mctx, MTCP_SOCK_EPOLL, FALSE);
	if (!epsocket) {
		errno = ENFILE;
		return -1;
	}

	ep = (struct mtcp_epoll *)calloc(1, sizeof(struct mtcp_epoll));
	if (!ep) {
		FreeSocket(mctx, epsocket->id, FALSE);
		return -1;
	}

	/* create event queues */
	ep->usr_queue = CreateEventQueue(size);
	if (!ep->usr_queue)
		return -1;

	ep->usr_shadow_queue = CreateEventQueue(size);
	if (!ep->usr_shadow_queue) {
		DestroyEventQueue(ep->usr_queue);
		return -1;
	}

	ep->mtcp_queue = CreateEventQueue(size);
	if (!ep->mtcp_queue) {
		DestroyEventQueue(ep->usr_queue);
		DestroyEventQueue(ep->usr_shadow_queue);
		return -1;
	}

	TRACE_EPOLL("epoll structure of size %d created.\n", size);

	mtcp->ep = ep;
	epsocket->ep = ep;

	if (pthread_mutex_init(&ep->epoll_lock, NULL)) {
		return -1;
	}
	if (pthread_cond_init(&ep->epoll_cond, NULL)) {
		return -1;
	}

	return epsocket->id;
}
Ejemplo n.º 2
0
void InputEventsWestonTest::SetUp()
{
  WestonTest::SetUp();
  
  clientLibrary.Load();
  eglLibrary.Load();
  xkbCommonLibrary.Load();
  
  xkbContext.reset(CXKBKeymap::CreateXKBContext(xkbCommonLibrary),
                   boost::bind(&IDllXKBCommon::xkb_context_unref,
                               &xkbCommonLibrary, _1));
  keymap.reset(new CXKBKeymap(
                 xkbCommonLibrary, 
                 CXKBKeymap::CreateXKBKeymapFromNames(xkbCommonLibrary,
                                                      xkbContext.get(),
                                                      "evdev",
                                                      "pc105",
                                                      "us",
                                                      "",
                                                      "")));
  
  display.reset(new xw::Display(clientLibrary));
  queue.reset(CreateEventQueue());
  registry.reset(new xw::Registry(clientLibrary,
                                  display->GetWlDisplay(),
                                  *this));
  loop.reset(new xwe::Loop(listener, *queue));

  /* Wait for the seat, shell, compositor to appear */
  WaitForSynchronize();
  
  ASSERT_TRUE(input.get() != NULL);
  ASSERT_TRUE(compositor.get() != NULL);
  ASSERT_TRUE(shell.get() != NULL);
  ASSERT_TRUE(xbmcWayland.get() != NULL);
  
  /* Wait for input devices to appear etc */
  WaitForSynchronize();
  
  surface.reset(new xw::Surface(clientLibrary,
                                compositor->CreateSurface()));
  shellSurface.reset(new xw::ShellSurface(clientLibrary,
                                          shell->CreateShellSurface(
                                            surface->GetWlSurface())));
  openGLSurface.reset(new xw::OpenGLSurface(eglLibrary,
                                            surface->GetWlSurface(),
                                            SurfaceWidth,
                                            SurfaceHeight));

  wl_shell_surface_set_toplevel(shellSurface->GetWlShellSurface());
  surface->Commit();
}
Ejemplo n.º 3
0
NS_IMETHODIMP
nsEventQueueServiceImpl::CreateFromIThread(nsIThread *aThread, PRBool aNative,
                                           nsIEventQueue **aResult)
{
  nsresult rv;
  PRThread *prThread;

  rv = aThread->GetPRThread(&prThread);
  if (NS_SUCCEEDED(rv)) {
    rv = CreateEventQueue(prThread, aNative); // addrefs
    if (NS_SUCCEEDED(rv))
      rv = GetThreadEventQueue(prThread, aResult); // addrefs
  }
  return rv;
}
Ejemplo n.º 4
0
nsresult
nsEventQueueServiceImpl::Init()
{
  NS_ENSURE_TRUE(mEventQMonitor, NS_ERROR_OUT_OF_MEMORY);

  // This will only be called once on the main thread, so it's safe to
  // not enter the monitor here.
  if (!mEventQTable.Init()) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  
  // ensure that a main thread event queue exists!
  nsresult rv;
  nsCOMPtr<nsIThread> mainThread;
  rv = nsIThread::GetMainThread(getter_AddRefs(mainThread));
  if (NS_SUCCEEDED(rv)) {
    PRThread *thr;
    rv = mainThread->GetPRThread(&thr);
    if (NS_SUCCEEDED(rv))
      rv = CreateEventQueue(thr, PR_TRUE);
  }
  return rv;
}
Ejemplo n.º 5
0
NS_IMETHODIMP
nsEventQueueServiceImpl::CreateMonitoredThreadEventQueue()
{
  return CreateEventQueue(PR_GetCurrentThread(), PR_FALSE);
}
Ejemplo n.º 6
0
NS_IMETHODIMP
nsEventQueueServiceImpl::CreateThreadEventQueue()
{
  return CreateEventQueue(PR_GetCurrentThread(), PR_TRUE);
}