MFLockSharedWorkQueue function (mfapi.h)

Obtains and locks a shared work queue.

Syntax

HRESULT MFLockSharedWorkQueue(
  [in]      PCWSTR wszClass,
  [in]      LONG   BasePriority,
  [in, out] DWORD  *pdwTaskId,
  [out]     DWORD  *pID
);

Parameters

[in] wszClass

The name of the MMCSS task.

[in] BasePriority

The base priority of the work-queue threads.

If the regular-priority queue is being used (wszClass=""), then the value 0 must be passed in.

[in, out] pdwTaskId

The MMCSS task identifier. On input, specify an existing MCCSS task group ID , or use the value zero to create a new task group. If the regular priority queue is being used (wszClass=""), then NULL must be passed in. On output, receives the actual task group ID.

[out] pID

Receives an identifier for the new work queue. Use this identifier when queuing work items.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

A multithreaded work queue uses a thread pool to dispatch work items. Whenever a thread becomes available, it dequeues the next work item from the queue. Work items are dequeued in first-in-first-out order, but work items are not serialized. In other words, the work queue does not wait for a work item to complete before it starts the next work item.

Within a single process, the Microsoft Media Foundation platform creates up to one multithreaded queue for each Multimedia Class Scheduler Service (MMCSS) task. The MFLockSharedWorkQueue function checks whether a matching work queue already exists. If not, the function creates a new work queue and registers the work queue with MMCSS. The function returns the MMCSS task identifier (pdwTaskId) and the work queue identifier (pID). To queue a work item, pass the work queue identifier to any of the following functions:

The MFLockSharedWorkQueue function also locks the queue. Before the process exits, call MFUnlockWorkQueue to unlock the work queue.

If the regular priority queue is being used (wszClass=""), then NULL must be passed in to pdwTaskId and the value 0 must be passed into BasePriority.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header mfapi.h
Library Mfplat.lib
DLL Mfplat.dll

See also

Media Foundation Functions

Work Queue and Threading Improvements

Work Queues