Task
Object Hierarchy:
Description:
public class Task :
Object
Task is used by Element and
Pad to provide the data passing threads in a Pipeline
. A Pad will typically start a Task to push or pull
data to/from the peer pads. Most source elements start a Task to push data. In some cases a
demuxer element can start a Task to pull data from a peer element. This is typically done when
the demuxer can perform random access on the upstream peer element for improved performance. Although convenience functions exist on
Pad to start/pause/stop tasks, it might sometimes be needed to create a
Task manually if it is not related to a Pad. Before the
Task can be run, it needs a
StaticRecMutex that can be set with set_lock. The task can be started, paused
and stopped with start, pause and
stop respectively or with the set_state
function. A Task will repeatedly call the
TaskFunction with the user data that was provided when creating the task with
create. While calling the function it will acquire the provided lock. The provided lock is released when the task pauses or stops.
Stopping a task with stop will not immediately make sure the task is not running anymore.
Use join to make sure the task is completely stopped and the thread is stopped. After
creating a Task, use unref to free its
resources. This can only be done it the task is not running anymore. Task functions can send a
Message to send out-of-band data to the application. The application can receive messages from the
Bus in its mainloop. For debugging perposes, the task will configure its object name as the
thread name on Linux. Please note that the object name should be configured before the task is started; changing the object name after the
task has been started, has no effect on the thread name. Last reviewed on 2010-03-15 (0.10.29)
Namespace: Gst
Package: gstreamer-0.10
Content:
Static methods:
Creation methods:
Methods:
-
public weak TaskPool get_pool ()
Get the TaskPool that this task will use for its streaming
threads. MT safe. after usage.
-
public TaskState get_state ()
Get the current state of the task. MT safe.
-
public bool join ()
Joins task. After this call, it is safe to unref the task and clean up the lock set with
set_lock. The task will automatically be stopped with this call. This function
cannot be called from within a task function as this would cause a deadlock. The function will detect this and print a g_warning. MT
safe.
-
public bool pause ()
Pauses task. This method can also be called on a task in the stopped state, in which case a
thread will be started and will remain in the paused state. This function does not wait for the task to complete the paused state. MT
safe.
-
public void set_lock (StaticRecMutex mutex)
Set the mutex used by the task. The mutex will be acquired before calling the
TaskFunction. This function has to be called before calling
pause or start. MT safe.
-
public void set_pool (TaskPool pool)
Set pool as the new GstTaskPool for task. Any new streaming threads that will
be created by task will now use pool. MT safe.
-
public void set_priority (ThreadPriority priority)
Changes the priority of task to priority. MT safe.
-
public bool set_state (TaskState state)
Sets the state of task to state. The task must have a lock
associated with it using set_lock when going to GST_TASK_STARTED or
GST_TASK_PAUSED or this function will return false. MT safe.
-
public void set_thread_callbacks (TaskThreadCallbacks callbacks, DestroyNotify notify)
Set callbacks which will be executed when a new thread is needed, the thread function is entered and
left and when the thread is joined. By default a thread for task will be created from a default thread pool. Objects can
use custom GThreads or can perform additional configuration of the threads (such as changing the thread priority) by installing
callbacks. MT safe.
-
public bool start ()
Starts task. The task must have a lock associated with it using
set_lock or this function will return false. MT safe.
-
public bool stop ()
Stops task. This method merely schedules the task to stop and will not wait for the task to
have completely stopped. Use join to stop and wait for completion. MT safe.
Fields: