View Javadoc

1   package net.sf.jack4j;
2   
3   /*
4   Copyright (C) 2008 Ondrej Par
5   
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU Lesser General Public License as published by
8   the Free Software Foundation; either version 2.1 of the License, or
9   (at your option) any later version.
10  
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU Lesser General Public License for more details.
15  
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  
20  */
21  
22  /**
23   * Allows operations on the thread associated with Jack client.
24   * 
25   * @author repa
26   * 
27   */
28  public class JackClientThread {
29  
30  	private JackClient jackClient;
31  	@SuppressWarnings("unused")
32  	private long clientHandle;
33  	private Thread thread;
34  
35  	JackClientThread(JackClient jackClient, long clientHandle, Thread thread) {
36  		this.jackClient = jackClient;
37  		this.clientHandle = clientHandle;
38  		this.thread = thread;
39  	}
40  
41  	/**
42  	 * @return the jackClient
43  	 */
44  	public JackClient getJackClient() {
45  		return jackClient;
46  	}
47  
48  	/**
49  	 * Returns the Java Thread that represents Jack POSIX client thread.
50  	 */
51  	public Thread getThread() {
52  		return thread;
53  	}
54  
55  	/**
56  	 * Returns client thread ID, packed as <code>long</code>.
57  	 */
58  	public native long clientThreadId();
59  
60  	/**
61  	 * Attempts to enable realtime scheduling for a thread.
62  	 * 
63  	 * <p>
64  	 * On some systems that may require special privileges.
65  	 * 
66  	 * @param priority
67  	 *            requested priority
68  	 * @return true if successful, false if the process lacks realtime
69  	 *         privileges
70  	 * @throws JackException
71  	 *             if other error occurred
72  	 */
73  	public native boolean acquireRealTimeScheduling(int priority) throws JackException;
74  
75  	/**
76  	 * Drop realtime scheduling for a thread.
77  	 */
78  	public native void dropRealTimeScheduling() throws JackException;
79  }