lundi 21 octobre 2019

How are we using Arguments in the Thread

I was reading some code where programmer first defined

   typedef void* BLUEVELVETC_HANDLE;

and than he used this variable in a struct.

struct ThreadArgs
{
    BLUEVELVETC_HANDLE pSDK;
    EBlueVideoChannel nVideoOutputChannel;
    BLUE_U32 VideoModeExt;
    EUpdateMethod UpdateFormat;
    EMemoryFormat MemoryFormat;
};

than he created a new thread and sent the struct as argument.

ThreadArgs args;
args.pSDK = pSDKOut;
args.nVideoOutputChannel = BLUE_VIDEOCHANNEL_A;
args.VideoModeExt = VideoModeExt;
args.UpdateFormat = UpdateFormat;
args.MemoryFormat = MemoryFormat;

unsigned int ThreadId = 0;
g_hThread = (HANDLE)_beginthreadex(NULL, 0, &PlaybackThreadFifoMode, &args, CREATE_SUSPENDED,&ThreadId);

and finally in this function he used the arguments.

  unsigned int __stdcall PlaybackThreadFifoMode(void* pArg)

  unsigned int __stdcall PlaybackThreadFifoMode(void* pArg)
 {
     ThreadArgs* pArgs = (ThreadArgs*)pArg;
    BLUEVELVETC_HANDLE pSDK = pArgs->pSDK;
 }

Can somebody kindly explain me what this code means.

Aucun commentaire:

Enregistrer un commentaire