]> git.sesse.net Git - vlc/blob - projects/macosx/framework/Headers/Internal/VLCEventManager.h
VLCKit: Import MobileVLCKit.
[vlc] / projects / macosx / framework / Headers / Internal / VLCEventManager.h
1 /*****************************************************************************
2  * VLCEventManager.h: VLCKit.framework VLCEventManager header
3  *****************************************************************************
4  * Copyright (C) 2007 Pierre d'Herbemont
5  * Copyright (C) 2007 the VideoLAN team
6  * $Id$
7  *
8  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #import <pthread.h>
26
27 /**
28  * The VLCEventManager class provides a safe way for inter-thread communications.
29  */
30 @interface VLCEventManager : NSObject
31 {
32     NSMutableArray *messageQueue;      //< Holds a queue of messages.
33     NSMutableArray *pendingMessagesOnMainThread;   //< Holds the message that are being posted on main thread.
34     NSLock          *pendingMessagesLock;
35     pthread_t        dispatcherThread;  //< Thread responsible for dispatching messages.
36     pthread_mutex_t  queueLock;         //< Queue lock.
37     pthread_cond_t   signalData;        //< Data lock.
38 }
39
40 /* Factories */
41 /**
42  * Returns the shared VLCEventManager.  There should only be one instance of this class.
43  * \return Shared event manager.
44  */
45 + (id)sharedManager;
46
47 /* Operations */
48 /**
49  * Sends a message to the target's delegate on the main thread.
50  * \discussion The main thread is the one in which the main run loop is run, which usually
51  * means the one in which the NSApplication object receives events. The method is performed
52  * when the main thread runs the run loop in one of the common run loop modes (as specified
53  * in the CFRunLoop documentation).
54  *
55  * The receiver is retained until the call is finished.
56  * \param aTarget The target object who's delegate should receive the specified message.
57  * \param aSelector A selector that identifies the method to invoke. The method should not
58  * have a significant return value and should take a single argument of type NSNotification,
59  * or no arguments.
60  *
61  * See “Selectors” for a description of the SEL type.
62  * \param aNotificiationName The name of the notification that should be sent to the
63  * distributed notification center.
64  */
65 - (void)callOnMainThreadDelegateOfObject:(id)aTarget
66                       withDelegateMethod:(SEL)aSelector
67                     withNotificationName:(NSString *)aNotificationName;
68
69 /**
70  * Sends a message to the target on the main thread.
71  * \discussion The main thread is the one in which the main run loop is run, which usually
72  * means the one in which the NSApplication object receives events. The method is performed
73  * when the main thread runs the run loop in one of the common run loop modes (as specified
74  * in the CFRunLoop documentation).
75  *
76  * The receiver and arg are retained until the call is finished.
77  * \param aTarget The target object who should receive the specified message.
78  * \param aSelector A selector that identifies the method to invoke. The method should not
79  * have a significant return value and should take a single argument of type id,
80  * or no arguments.
81  *
82  * See “Selectors” for a description of the SEL type.
83  * \param arg The argument to pass in the message.  Pass nil if the method does not take an
84  * argument.
85  * distributed notification center.
86  */
87 - (void)callOnMainThreadObject:(id)aTarget
88                     withMethod:(SEL)aSelector
89           withArgumentAsObject:(id)arg;
90
91 - (void)cancelCallToObject:(id)target;
92 @end