]> git.sesse.net Git - vlc/blob - projects/macosx/framework/Headers/Internal/VLCEventManager.h
a7a06d204f94840f7ae81858cb32dbc0617d1516
[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 <Cocoa/Cocoa.h>
26 #import <pthread.h>
27
28 /**
29  * The VLCEventManager class provides a safe way for inter-thread communications.
30  */
31 @interface VLCEventManager : NSObject
32 {
33     NSMutableArray * messageQueue;      //< Holds a queue of messages.
34     pthread_t        dispatcherThread;  //< Thread responsible for dispatching messages.
35     pthread_mutex_t  queueLock;         //< Queue lock.
36     pthread_cond_t   signalData;        //< Data lock.
37 }
38
39 /* Factories */
40 /**
41  * Returns the shared VLCEventManager.  There should only be one instance of this class.
42  * \return Shared event manager.
43  */
44 + (id)sharedManager;
45
46 /* Operations */
47 /**
48  * Sends a message to the target's delegate on the main thread.
49  * \discussion The main thread is the one in which the main run loop is run, which usually 
50  * means the one in which the NSApplication object receives events. The method is performed 
51  * when the main thread runs the run loop in one of the common run loop modes (as specified 
52  * in the CFRunLoop documentation).
53  *
54  * The receiver is retained until the call is finished.
55  * \param aTarget The target object who's delegate should receive the specified message.
56  * \param aSelector A selector that identifies the method to invoke. The method should not 
57  * have a significant return value and should take a single argument of type NSNotification, 
58  * or no arguments.
59  *
60  * See “Selectors” for a description of the SEL type.
61  * \param aNotificiationName The name of the notification that should be sent to the 
62  * distributed notification center.
63  */
64 - (void)callOnMainThreadDelegateOfObject:(id)aTarget 
65                       withDelegateMethod:(SEL)aSelector 
66                     withNotificationName:(NSString *)aNotificationName;
67
68 /**
69  * Sends a message to the target on the main thread.
70  * \discussion The main thread is the one in which the main run loop is run, which usually 
71  * means the one in which the NSApplication object receives events. The method is performed 
72  * when the main thread runs the run loop in one of the common run loop modes (as specified 
73  * in the CFRunLoop documentation).
74  *
75  * The receiver and arg are retained until the call is finished.
76  * \param aTarget The target object who should receive the specified message.
77  * \param aSelector A selector that identifies the method to invoke. The method should not 
78  * have a significant return value and should take a single argument of type id, 
79  * or no arguments.
80  *
81  * See “Selectors” for a description of the SEL type.
82  * \param arg The argument to pass in the message.  Pass nil if the method does not take an 
83  * argument.
84  * distributed notification center.
85  */
86 - (void)callOnMainThreadObject:(id)aTarget 
87                     withMethod:(SEL)aSelector 
88           withArgumentAsObject:(id)arg;
89 @end