VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/threads/nsEventQueue.h@ 44770

最後變更 在這個檔案從44770是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.5 KB
 
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is Mozilla Communicator client code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Pierre Phaneuf <[email protected]>
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39#include "prmon.h"
40#include "nsIEventQueue.h"
41#include "nsPIEventQueueChain.h"
42
43class nsEventQueueImpl : public nsIEventQueue,
44 public nsPIEventQueueChain
45{
46public:
47 nsEventQueueImpl();
48
49 NS_DECL_ISUPPORTS
50 NS_DECL_NSIEVENTTARGET
51 NS_DECL_NSIEVENTQUEUE
52
53 // Helpers
54 static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
55
56 static const nsCID& CID() { static nsCID cid = NS_EVENTQUEUE_CID; return cid; }
57
58 // nsPIEventQueueChain interface
59 NS_IMETHOD AppendQueue(nsIEventQueue *aQueue);
60 NS_IMETHOD Unlink();
61 NS_IMETHOD GetYoungest(nsIEventQueue **aQueue);
62 NS_IMETHOD GetYoungestActive(nsIEventQueue **aQueue);
63 NS_IMETHOD SetYounger(nsPIEventQueueChain *aQueue);
64 NS_IMETHOD GetYounger(nsIEventQueue **aQueue);
65 NS_IMETHOD SetElder(nsPIEventQueueChain *aQueue);
66 NS_IMETHOD GetElder(nsIEventQueue **aQueue);
67
68private:
69 ~nsEventQueueImpl();
70
71 PLEventQueue *mEventQueue;
72 PRBool mAcceptingEvents, // accept new events or pass them on?
73 mCouldHaveEvents; // accepting new ones, or still have old ones?
74 nsCOMPtr<nsPIEventQueueChain> mElderQueue; // younger can hold on to elder
75 nsPIEventQueueChain *mYoungerQueue; // but elder can't hold on to younger
76
77 void NotifyObservers(const char *aTopic);
78
79 void CheckForDeactivation() {
80 if (mCouldHaveEvents && !mAcceptingEvents && !PL_EventAvailable(mEventQueue)) {
81 if (PL_IsQueueOnCurrentThread(mEventQueue)) {
82 mCouldHaveEvents = PR_FALSE;
83 NS_RELEASE_THIS(); // balance ADDREF from the constructor
84 } else
85 NS_ERROR("CheckForDeactivation called from wrong thread!");
86 }
87 }
88};
89
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette