Export (0) Print
Expand All
Expand Minimize

CreateFiberEx function

Allocates a fiber object, assigns it a stack, and sets up execution to begin at the specified start address, typically the fiber function. This function does not schedule the fiber.

Syntax


LPVOID WINAPI CreateFiberEx(
  _In_      SIZE_T dwStackCommitSize,
  _In_      SIZE_T dwStackReserveSize,
  _In_      DWORD dwFlags,
  _In_      LPFIBER_START_ROUTINE lpStartAddress,
  _In_opt_  LPVOID lpParameter
);

Parameters

dwStackCommitSize [in]

The initial commit size of the stack, in bytes. If this parameter is zero, the new fiber uses the default commit stack size for the executable. For more information, see Thread Stack Size.

dwStackReserveSize [in]

The initial reserve size of the stack, in bytes. If this parameter is zero, the new fiber uses the default reserved stack size for the executable. For more information, see Thread Stack Size.

dwFlags [in]

If this parameter is zero, the floating-point state on x86 systems is not switched and data can be corrupted if a fiber uses floating-point arithmetic. If this parameter is FIBER_FLAG_FLOAT_SWITCH, the floating-point state is switched for the fiber.

Windows XP:  The FIBER_FLAG_FLOAT_SWITCH flag is not supported.

lpStartAddress [in]

A pointer to the application-defined function to be executed by the fiber and represents the starting address of the fiber. Execution of the newly created fiber does not begin until another fiber calls the SwitchToFiber function with this address. For more information on the fiber callback function, see FiberProc.

lpParameter [in, optional]

A pointer to a variable that is passed to the fiber. The fiber can retrieve this data by using the GetFiberData macro.

Return value

If the function succeeds, the return value is the address of the fiber.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The number of fibers a process can create is limited by the available virtual memory. By default, every fiber has 1 megabyte of reserved stack space. Therefore, you can create at most 2028 fibers. If you reduce the default stack size, you can create more fibers. However, your application will have better performance if you use an alternate strategy for processing requests.

Before a thread can schedule a fiber using the SwitchToFiber function, it must call the ConvertThreadToFiber function so there is a fiber associated with the thread.

To compile an application that uses this function, define _WIN32_WINNT as 0x0400 or later. For more information, see Using the Windows Headers.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

ConvertThreadToFiber
FiberProc
Fibers
GetFiberData
Process and Thread Functions
SwitchToFiber

 

 

Community Additions

ADD
Show:
© 2014 Microsoft