Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libjitsi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZRTP
libjitsi
Commits
76de39d3
Commit
76de39d3
authored
10 years ago
by
Lyubomir Marinov
Browse files
Options
Downloads
Patches
Plain Diff
Extracts a thread pool-creating method as a utility function.
parent
045941d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/org/jitsi/impl/neomedia/transform/csrc/CsrcAudioLevelDispatcher.java
+10
-35
10 additions, 35 deletions
...mpl/neomedia/transform/csrc/CsrcAudioLevelDispatcher.java
src/org/jitsi/util/ExecutorUtils.java
+76
-0
76 additions, 0 deletions
src/org/jitsi/util/ExecutorUtils.java
with
86 additions
and
35 deletions
src/org/jitsi/impl/neomedia/transform/csrc/CsrcAudioLevelDispatcher.java
+
10
−
35
View file @
76de39d3
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package
org.jitsi.impl.neomedia.transform.csrc
;
import
java.util.concurrent.*
;
import
org.jitsi.impl.neomedia.*
;
import
org.jitsi.util.*
;
/**
* A simple thread that waits for new levels to be reported from incoming
...
...
@@ -21,41 +28,9 @@ public class CsrcAudioLevelDispatcher
* <tt>CsrcAudioLevelDispatcher</tt>s.
*/
private
static
final
ExecutorService
threadPool
=
Executors
.
newCachedThreadPool
(
new
ThreadFactory
()
{
/**
* The default <tt>ThreadFactory</tt> implementation which
* is augmented by this instance to create daemon
* <tt>Thread</tt>s.
*/
private
final
ThreadFactory
defaultThreadFactory
=
Executors
.
defaultThreadFactory
();
@Override
public
Thread
newThread
(
Runnable
r
)
{
Thread
t
=
defaultThreadFactory
.
newThread
(
r
);
if
(
t
!=
null
)
{
t
.
setDaemon
(
true
);
/*
* Additionally, make it known through the name of
* the Thread that it is associated with the
* CsrcAudioLevelDispatcher class for
* debugging/informational purposes.
*/
String
name
=
t
.
getName
();
if
(
name
==
null
)
name
=
""
;
t
.
setName
(
"CsrcAudioLevelDispatcher-"
+
name
);
}
return
t
;
}
});
=
ExecutorUtils
.
newCachedThreadPool
(
true
,
"CsrcAudioLevelDispatcher"
);
/** The levels that we last received from the reverseTransform thread*/
private
long
[]
lastReportedLevels
=
null
;
...
...
This diff is collapsed.
Click to expand it.
src/org/jitsi/util/ExecutorUtils.java
0 → 100644
+
76
−
0
View file @
76de39d3
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package
org.jitsi.util
;
import
java.util.concurrent.*
;
/**
* Implements utility functions to facilitate work with <tt>Executor</tt>s and
* <tt>ExecutorService</tt>.
*
* @author Lyubomir Marinov
*/
public
class
ExecutorUtils
{
/**
* Creates a thread pool that creates new threads as needed, but will reuse
* previously constructed threads when they are available. Optionally, the
* new threads are created as daemon threads and their names are based on a
* specific (prefix) string.
*
* @param daemon <tt>true</tt> to create the new threads as daemon threads
* or <tt>false</tt> to create the new threads as user threads
* @param baseName the base/prefix to use for the names of the new threads
* or <tt>null</tt> to leave them with their default names
* @return the newly created thread pool
*/
public
static
ExecutorService
newCachedThreadPool
(
final
boolean
daemon
,
final
String
baseName
)
{
return
Executors
.
newCachedThreadPool
(
new
ThreadFactory
()
{
/**
* The default <tt>ThreadFactory</tt> implementation
* which is augmented by this instance to create daemon
* <tt>Thread</tt>s.
*/
private
final
ThreadFactory
defaultThreadFactory
=
Executors
.
defaultThreadFactory
();
@Override
public
Thread
newThread
(
Runnable
r
)
{
Thread
t
=
defaultThreadFactory
.
newThread
(
r
);
if
(
t
!=
null
)
{
t
.
setDaemon
(
daemon
);
/*
* Additionally, make it known through the name
* of the Thread that it is associated with the
* specified class for debugging/informational
* purposes.
*/
if
((
baseName
!=
null
)
&&
(
baseName
.
length
()
!=
0
))
{
String
name
=
t
.
getName
();
if
(
name
==
null
)
name
=
""
;
t
.
setName
(
baseName
+
"-"
+
name
);
}
}
return
t
;
}
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment