Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsEventQueueServiceImpl Class Reference

#include <nsEventQueueService.h>

Inheritance diagram for nsEventQueueServiceImpl:
Inheritance graph
[legend]
Collaboration diagram for nsEventQueueServiceImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsEventQueueServiceImpl ()
nsresult Init ()
void createThreadEventQueue ()
 Creates and holds a native event queue for the current thread.
void createMonitoredThreadEventQueue ()
 Creates and hold a monitored event queue for the current thread.
void destroyThreadEventQueue ()
 Somewhat misnamed, this method releases the service's hold on the event queue(s) for this thread.
nsIEventQueue createFromIThread (in nsIThread aThread, in boolean aNative)
nsIEventQueue createFromPLEventQueue (in PLEventQueuePtr aPLEventQueue)
nsIEventQueue pushThreadEventQueue ()
void popThreadEventQueue (in nsIEventQueue aQueue)
nsIEventQueue getThreadEventQueue (in PRThreadPtr aThread)
nsIEventQueue resolveEventQueue (in nsIEventQueue queueOrConstant)
nsIEventQueue getSpecialEventQueue (in long aQueue)
 Returns the appropriate special event queue, AddRef()ed.

Public Attributes

const long CURRENT_THREAD_EVENT_QUEUE = 0
const long UI_THREAD_EVENT_QUEUE = 1

Private Member Functions

 ~nsEventQueueServiceImpl ()
NS_IMETHOD CreateEventQueue (PRThread *aThread, PRBool aNative)
NS_IMETHOD MakeNewQueue (PRThread *thread, PRBool aNative, nsIEventQueue **aQueue)
nsresult GetYoungestEventQueue (nsIEventQueue *queue, nsIEventQueue **aResult)

Private Attributes

nsInterfaceHashtable
< nsVoidPtrHashKey,
nsIEventQueue
mEventQTable
PRMonitormEventQMonitor

Detailed Description

Definition at line 48 of file nsEventQueueService.h.


Constructor & Destructor Documentation

Definition at line 68 of file nsEventQueueService.cpp.

{
  mEventQMonitor = PR_NewMonitor();
#if defined(PR_LOGGING) && defined(DEBUG_danm)
  if (!gEventQueueLog)
    gEventQueueLog = PR_NewLogModule("nseventqueue");
#endif
}

Here is the call graph for this function:

Definition at line 98 of file nsEventQueueService.cpp.

{
  // XXX make it so we only enum over this once
  mEventQTable.Enumerate(hash_enum_remove_queues, nsnull); // call StopAcceptingEvents on everything and clear out the hashtable

  PR_DestroyMonitor(mEventQMonitor);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 184 of file nsEventQueueService.cpp.

{
  nsresult rv = NS_OK;
  /* Enter the lock that protects the EventQ hashtable... */
  PR_EnterMonitor(mEventQMonitor);

  /* create only one event queue chain per thread... */
  if (!mEventQTable.GetWeak(aThread)) {
    nsCOMPtr<nsIEventQueue> queue;

    // we don't have one in the table, create new queue
    rv = MakeNewQueue(aThread, aNative, getter_AddRefs(queue));
    if (NS_SUCCEEDED(rv))
      mEventQTable.Put(aThread, queue); // add to the table (initial addref)
  }

  // Release the EventQ lock...
  PR_ExitMonitor(mEventQMonitor);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Creates and hold a monitored event queue for the current thread.

"Monitored" queues have no callback processing mechanism.

Returns:
NS_OK on success, or a host of failure indications

Creates and holds a native event queue for the current thread.

"Native" queues have an associated callback mechanism which is automatically triggered when an event is posted. See plevent.c for details.

Returns:
NS_OK on success, or a host of failure indications

Somewhat misnamed, this method releases the service's hold on the event queue(s) for this thread.

Subsequent attempts to access this thread's queue (GetThreadEventQueue, for example) may fail, though the queue itself will be destroyed only after all references to it are released and the queue itself is no longer actively processing events.

Returns:
nonsense.

Returns the appropriate special event queue, AddRef()ed.

Really just a scriptable version of ResolveEventQueue.

  • aQueue Either CURRENT_THREAD_EVENT_QUEUE or UI_THREAD_EVENT_QUEUE
    Returns:
    The requested nsIEventQueue, AddRef()ed
    Exceptions:
    NS_ERROR_NULL_POINTERZero pointer passed in for return value
    NS_ERROR_ILLEGAL_VALUEBogus constant passed in aQueue
    NS_ERROR_FAILUREError while calling GetThreadEventQueue()

Definition at line 246 of file nsEventQueueService.cpp.

{
  nsCOMPtr<nsIEventQueue> answer;

  if (queue) {
    nsCOMPtr<nsPIEventQueueChain> ourChain(do_QueryInterface(queue));
    if (ourChain)
      ourChain->GetYoungestActive(getter_AddRefs(answer));
    else
      answer = queue;
  }

  *aResult = answer;
  NS_IF_ADDREF(*aResult);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 107 of file nsEventQueueService.cpp.

{
  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;
}

Here is the call graph for this function:

NS_IMETHODIMP nsEventQueueServiceImpl::MakeNewQueue ( PRThread thread,
PRBool  aNative,
nsIEventQueue **  aQueue 
) [private]

Definition at line 165 of file nsEventQueueService.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIEventQueue> queue = do_CreateInstance(kEventQueueCID, &rv);

  if (NS_SUCCEEDED(rv)) {
    rv = queue->InitFromPRThread(thread, aNative);
    if (NS_FAILED(rv))
      queue = nsnull;
  }
  *aQueue = queue;
  NS_IF_ADDREF(*aQueue);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Deprecated:
in favor of getSpecialEventQueue, since that's scriptable and this isn't.

Check for any "magic" event queue constants (NS_CURRENT_EVENTQ, NS_UI_THREAD_EVENTQ) and return the real event queue that they represent, AddRef()ed. Otherwise, return the event queue passed in, AddRef()ed. This is not scriptable because the arguments in question may be magic constants rather than real nsIEventQueues.

  • queueOrConstant either a real event queue or a magic constant to be resolved
Returns:
a real event queue, AddRef()ed

Member Data Documentation

Definition at line 148 of file nsIEventQueueService.idl.

Definition at line 72 of file nsEventQueueService.h.

Definition at line 71 of file nsEventQueueService.h.

Definition at line 149 of file nsIEventQueueService.idl.


The documentation for this class was generated from the following files: