1 /*****************************************************************************
2 * VLCEventManager.h: VLCKit.framework VLCEventManager header
3 *****************************************************************************
4 * Copyright (C) 2007 Pierre d'Herbemont
5 * Copyright (C) 2007 the VideoLAN team
8 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
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.
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.
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 *****************************************************************************/
25 #import <Cocoa/Cocoa.h>
29 * The VLCEventManager class provides a safe way for inter-thread communications.
31 @interface VLCEventManager : NSObject
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.
41 * Returns the shared VLCEventManager. There should only be one instance of this class.
42 * \return Shared event manager.
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).
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,
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.
64 - (void)callOnMainThreadDelegateOfObject:(id)aTarget
65 withDelegateMethod:(SEL)aSelector
66 withNotificationName:(NSString *)aNotificationName;
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).
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,
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
84 * distributed notification center.
86 - (void)callOnMainThreadObject:(id)aTarget
87 withMethod:(SEL)aSelector
88 withArgumentAsObject:(id)arg;