c++ event sink

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric Kaplan

    c++ event sink

    I have a function that will download XML from internet and load XML
    data into database.

    The function will take 5 - 20 minutes to finish.

    I heard I should use event sink (event listener) when function is
    finished the task, then it will notify the caller.

    So I am planning to create a seperate thread to do the long XML
    loading function by using - _beginthreadex( )

    But how to create a notification / event sink / event listener in C++?

    any library can easily just a library function call?

    or any sample source code on the internet?

    Thanks
  • Sam

    #2
    Re: c++ event sink

    Eric Kaplan writes:
    I heard I should use event sink (event listener) when function is
    finished the task, then it will notify the caller.
    >
    So I am planning to create a seperate thread to do the long XML
    loading function by using - _beginthreadex( )
    >
    But how to create a notification / event sink / event listener in C++?
    There's no such thing as a "notificati on", an "event sink", or an "event
    listener", in the C++ programming language.

    You must be referring to objects, or APIs, that are particular to whatever
    operating system you are using.

    You have a better chance of finding a helpful answer to your question if you
    ask, instead, on a different newsgroup that's specific to whatever operating
    system or library that you are using.


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)

    iD8DBQBIATtex9p 3GYHlUOIRAjhcAJ 94mbaefTJI9hrDv jxnDfDcWxizYgCf YAfy
    tb/KKifAaN9arrDj/hA0FHo=
    =kw0k
    -----END PGP SIGNATURE-----

    Comment

    • Alf P. Steinbach

      #3
      Re: c++ event sink

      * Eric Kaplan:
      I have a function that will download XML from internet and load XML
      data into database.
      >
      The function will take 5 - 20 minutes to finish.
      >
      I heard I should use event sink (event listener) when function is
      finished the task, then it will notify the caller.
      >
      So I am planning to create a seperate thread to do the long XML
      loading function by using - _beginthreadex( )
      Why not a separate process?

      Perhaps the user wants to terminate the UI part, but wants the download to complete.

      But how to create a notification / event sink / event listener in C++?
      If you have a GUI then you (probably) already have such functionality.

      But anyway take a look at e.g. Boost slots.

      any library can easily just a library function call?
      Huh.

      or any sample source code on the internet?
      Extremely much. Go look. :-)


      Cheers, & hth.,

      - Alf

      Comment

      • Eric Kaplan

        #4
        Re: c++ event sink


        that's a very good point, how to start a seperate process from the
        code?

        and how can I notify the caller when the process is finished?
        >
        >Why not a separate process?
        >

        Comment

        • Alf P. Steinbach

          #5
          Re: c++ event sink

          * Eric Kaplan:
          that's a very good point, how to start a seperate process from the
          code?
          In standard C++ and C all you have is the 'system' function, which is not
          adequate for your purposes.

          Essentially the question is therefore environment-specific, with best answers in
          an environment-specific group.

          The FAQ lists a few such groups.

          and how can I notify the caller when the process is finished?
          Again, system-specific. E.g., in Windows, which is what I know best, you can
          use mailslots (which are essentially datagrams camouflaged via file
          abstraction), pipes, any waitable global object, socket programming, real files,
          higher level COM object, message queues, window messages, and more, it's like
          they say just your fantasy that sets the limits, but it's all off-topic here in
          clc++, sorry!


          Cheers, & hth.,

          - Alf

          Comment

          • sk_usenet

            #6
            Re: c++ event sink


            "Eric Kaplan" <tobycraftse@ya hoo.comwrote in message
            >I have a function that will download XML from internet and load XML
            data into database.
            >
            The function will take 5 - 20 minutes to finish.
            >
            I heard I should use event sink (event listener) when function is
            finished the task, then it will notify the caller.
            >
            So I am planning to create a seperate thread to do the long XML
            loading function by using - _beginthreadex( )
            There is no concept of thread or process as far as the C++ language is
            concerned. People would scream your question as OT here :-). You should try
            your platform specific newsgroup.
            But how to create a notification / event sink / event listener in C++?
            >
            any library can easily just a library function call?
            >
            or any sample source code on the internet?
            Search engines are your friend.
            --



            Comment

            • sk_usenet

              #7
              Re: c++ event sink


              "Stefan Ram" <ram@zedat.fu-berlin.dewrote in message
              "sk_usenet" <sometechyguy at gmail dot comwrites:
              >>There is no concept of thread or process as far as the C++
              >>language is concerned.
              >
              »When an exception is thrown, control is transferred to
              the nearest handler with a matching type (15.3); "nearest"
              means the handler for which the compound-statement,
              ctor-initializer, or function-body following the try
              keyword was most recently entered by the thread of control
              and not yet exited.« ¯¯¯¯¯¯
              >
              ISO/IEC 14882:2003(E), 15.1p2
              >
              »If a function is registered with atexit (see <cstdlib>,
              18.3) then following the call to exit, any objects with
              static storage duration initialized prior to the
              registration of that function shall not be destroyed until
              the registered function is called from the termination
              process and has completed.«
              ¯¯¯¯¯¯¯
              ISO/IEC 14882:2003(E), 3.6.3p3
              Ok, pedantically speaking Standard does recognize something of a thread, and
              something of a process. But the bottom line is that OP's question was
              off-topic.


              Comment

              • migroslinx

                #8
                Re: c++ event sink

                Read http://libsigc.sourceforge.net/

                Comment

                • Eric Kaplan

                  #9
                  Re: c++ event sink

                  Thanks your hint!

                  but i think it may not be a good idea to use such big library for a
                  small task.

                  Does using call back function a good idea in here? (loading XML to
                  DB, after finish, notify the main / primary thread)




                  Comment

                  • Davis King

                    #10
                    Re: c++ event sink

                    On Apr 13, 4:39 am, Eric Kaplan <tobycraf...@ya hoo.comwrote:
                    Thanks your hint!
                    >
                    but i think it may not be a good idea to use such big library for a
                    small task.
                    >
                    Does using call back function a good idea in here? (loading XML to
                    DB, after finish, notify the main / primary thread)
                    >
                    Readhttp://libsigc.sourcef orge.net/
                    I believe you can also use the boost::bind library (http://
                    https://www.boost.org/doc/libs/1_35_...bind/bind.html) to create the sort
                    of callbacks you would be interested in.

                    You might also want to take a look at the
                    dlib::member_fu nction_pointer object which is similar but may be
                    easier to use depending on what you are trying to accomplish. See,
                    http://dclib.sourceforge.net/other.h...nction_pointer and


                    -Davis

                    Comment

                    Working...