Second Life source Analysis (45) Image decompression Thread

Source: Internet
Author: User
Tags thread class
The thread that describes the virtual filesystem, in fact, is a single thread that handles all messages, as well as a class lllfsthread. In the Second Life display software, the picture is accounted for most of the data, then downloaded from the server data, are compressed pictures, such a smaller picture size, for network communications need not too much bandwidth, see the program display speed significantly faster. Here is an analysis of how this thread works. Llappviewer::simagedecodethread = new Llworkerthread ("Imagedecode", enable_threads && true); The above line of code is the creation of an image decoding worker thread.   Llimageworker::initclass (Llappviewer::getimagedecodethread ()); This line of code sets the image decoding work to be done by the worker thread Simagedecodethread, because the Getimagedecodethread function returns a thread that is the Simagedecodethread member above.   from the creation line Chengri also see a Class Llworkerthread object, Class Llworkerthread is inheriting the thread class Llqueuedthread. The Llimageworker class can keep doing the work that needs to be done in the thread simagedecodethread, thus realizing the image decoding.   #001  class llimageworker:public llworkerclass #002  {#003  public: #004         static void Initclass (llworkerthread* workerthread); #005        static void Cleanupclass (); #006        static llworkerthread* Getworkerthread () {return sworkerthread;} #007   #008 & nbsp     //Llworkerthread #009 public: #010        llimageworker (llimageformatted* image, U32 priority, S32 discard, # 011                               LLPointer<LLResponder> Responder); #012        ~llimageworker (); #013   #014       //called from WORKER THREAD, returns TRUE if done #015     & nbsp; /*virtual*/bool DoWork (S32 param); #016        #017        BOOL requestdecodeddata (llpointer< llimageraw>& raw, S32 discard =-1); #018        BOOL requestdecodedauxdata (llpointer<llimageraw>& Raw, S32 channel, S32 Discard =-1); #019        void Releasedecodeddata (); #020        void Canceldecode (); #021   #022  private: #023 &nbSp     //called from MAIN THREAD #024       /*virtual*/void Startwork (S32 pa RAM); Called from Addwork () #025       /*virtual*/void endwork (S32 param, bool aborted); Called from DoWork () #026   #027  protected: #028        llpointer< Llimageformatted> Mformattedimage; #029        llpointer<llimageraw> mdecodedimage; #030        S32 mdecodedtype; #031        S32 mdiscardlevel; #032   #033  private: #034        U32 mpriority; #035        llpointer<llresponder> Mresponder; #036        #037  protected: #038        Static llworkerthread* Sworkerthread; #039   #040  public: #041        static S32 Scount; #042  }; #043     In this class, first call the Startwork function to openStart thread work, and then constantly call Requestdecodeddata, requestdecodedauxdata to send data to the thread to decode, and then by the thread to invoke DoWork to do this work, and finally call Endwork to end the work.  

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.