Windows core Programming: the 12th Chapter fiber

Source: Internet
Author: User

Github

Https://github.com/gongluck/Windows-Core-Program.git

12th. CPP: Defines the entry point for the application. #include "stdafx.h" #include "the 12th Chapter fiber. h" lpvoid G_covert = Nullptr;dword g_index = 0;    VOID WINAPI Fiberfun (lpvoid lpfiberparameter) {//fiber parameter LPVoid pfibercurrent = Getcurrentfiber ();    BOOL Bres = Isthreadafiber (); LPVOID pcurrentdata = GetFiberData ();//Get parameters passed when creating fiber, pcurrentdata==lpfiberparameter==555//fiber local Storage Bres = Flssetvalue    (G_index, (PVOID) 200);    PVOID Flsvalue = Flsgetvalue (G_index); SwitchToFiber (G_covert);} VOID Ntapi flsfun (in PVOID lpflsdata) {//flssetvalue How many times, system calls Flsfun how many times//can be actively called Flsfree delete FLS slots//fiber destruction when also called Flsfun}in T apientry wWinMain (_in_ hinstance hinstance, _in_opt_ hinstance hprevinstance, _in_ lpwstr lpCmdLine, _In_ in    T ncmdshow) {//convert thread to fiber lpvoid Pfibercovert = Convertthreadtofiberex (nullptr, Fiber_flag_float_switch);    G_covert = Pfibercovert;    Fiber Local Storage Area G_index = Flsalloc (Flsfun);    BOOL Bres = Flssetvalue (G_index, (PVOID) 100);    PVOID Flsvalue = Flsgetvalue (G_index);    Create fiberLPVOID pfibercreate = Createfiberex (0, 0, Fiber_flag_float_switch, Fiberfun, (LPVOID) 555);    Switch fiber SwitchToFiber (pfibercreate);        Bres = Flsfree (G_index);    Destruction of fiber deletefiber (pfibercreate);    The fiber state of the thread is lifted Bres = Convertfibertothread ();    System ("pause"); return 0;}

Windows core programming: 12th Fiber

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.