1 /* |
|
2 * Copyright (c) 2001 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.mj.impl.rt.legacy; |
|
20 |
|
21 import com.nokia.mj.impl.rt.support.Jvm; |
|
22 |
|
23 /** |
|
24 * A class for dispatcher thread handling. |
|
25 */ |
|
26 class EventProcessor extends Thread |
|
27 { |
|
28 |
|
29 /** |
|
30 * The Event dispatcher thread. |
|
31 */ |
|
32 private static EventProcessor mEventProcessor; |
|
33 |
|
34 /** |
|
35 * The Notify dispatcher thread. |
|
36 */ |
|
37 private static EventProcessor mNotifyProcessor; |
|
38 |
|
39 /** |
|
40 * The thread id. 0=event dispatcher, 1= notify dispatcher. |
|
41 */ |
|
42 private int mThreadId; |
|
43 |
|
44 static |
|
45 { |
|
46 Jvm.loadSystemLibrary("javalegacyutils"); |
|
47 } |
|
48 |
|
49 /** |
|
50 * Create the dispatcher threads if don't exist. |
|
51 */ |
|
52 static synchronized void startEventProcessing() |
|
53 { |
|
54 if (mEventProcessor == null) |
|
55 { |
|
56 mEventProcessor = new EventProcessor(0); |
|
57 mEventProcessor.start(); |
|
58 mNotifyProcessor = new EventProcessor(1); |
|
59 mNotifyProcessor.start(); |
|
60 } |
|
61 } |
|
62 |
|
63 private EventProcessor(int threadId) |
|
64 { |
|
65 super(null, "EventProcessor"); |
|
66 mThreadId = threadId; |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 * The dispatcher threads makes only upcalls from Java. |
|
72 */ |
|
73 public void run() |
|
74 { |
|
75 _dispatchCallbacks(mThreadId); |
|
76 } |
|
77 |
|
78 /** |
|
79 * Called to exit the dispatcher threads. Interrupts the threads |
|
80 */ |
|
81 static void exitThreads() |
|
82 { |
|
83 _exitThreads(); |
|
84 } |
|
85 |
|
86 |
|
87 // Native method to cleanup the native event server stuff |
|
88 private static native void _dispatchCallbacks(int threadId); |
|
89 private static native void _exitThreads(); |
|
90 } |
|
91 // eof |
|