Symbian3/PDK/Source/GUID-6CF8A41B-C2DD-5D57-A71D-6405CE08A06B.dita
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
equal deleted inserted replaced
4:4816d766a08a 5:f345bda72bc4
     7     Nokia Corporation - initial contribution.
     7     Nokia Corporation - initial contribution.
     8 Contributors: 
     8 Contributors: 
     9 -->
     9 -->
    10 <!DOCTYPE concept
    10 <!DOCTYPE concept
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    12 <concept xml:lang="en" id="GUID-6CF8A41B-C2DD-5D57-A71D-6405CE08A06B"><title>Using Signals to Handle Asynchronous Events</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>You can use signals to handle asynchronous user events. A process (program code) can send a signal to itself that can be handled asynchronously based on the signal handler registered for it. This provides a way to perform tasks in parallel without any complex thread manipulation in the program code. </p> <p>The following example code demonstrates how a program code sets a signal to itself and how it handles the signal asynchronously in a signal handler: </p> <codeblock id="GUID-4424321B-112A-5556-AD29-41F613A60C84" xml:space="preserve">#include &lt;signal.h&gt;
    12 <concept id="GUID-6CF8A41B-C2DD-5D57-A71D-6405CE08A06B" xml:lang="en"><title>Using
       
    13 Signals to Handle Asynchronous Events</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>You can use signals to handle asynchronous user events. A process (program
       
    15 code) can send a signal to itself that can be handled asynchronously based
       
    16 on the signal handler registered for it. This provides a way to perform tasks
       
    17 in parallel without any complex thread manipulation in the program code. </p>
       
    18 <p>The following example code demonstrates how a program code sets a signal
       
    19 to itself and how it handles the signal asynchronously in a signal handler: </p>
       
    20 <codeblock id="GUID-4424321B-112A-5556-AD29-41F613A60C84" xml:space="preserve">#include &lt;signal.h&gt;
    13 #include &lt;stdio.h&gt;
    21 #include &lt;stdio.h&gt;
    14 void sighandler(int signum)
    22 void sighandler(int signum)
    15     {
    23     {
    16     if(signum == SIGUSR1)
    24     if(signum == SIGUSR1)
    17         {
    25         {
    30     raise(SIGUSR1); // indicates user event one
    38     raise(SIGUSR1); // indicates user event one
    31     // program logic
    39     // program logic
    32     raise(SIGUSR2); // indicates user event two
    40     raise(SIGUSR2); // indicates user event two
    33     // program logic
    41     // program logic
    34     return 0;
    42     return 0;
    35     }</codeblock> </conbody><related-links><link href="GUID-66C1493D-5B85-558A-9A39-454E6EBA307B.dita"><linktext>Signal Emulation on Symbian
    43     }</codeblock>
    36                 Platform</linktext> </link> <link href="GUID-186B9876-2A08-5F23-BB49-49EC34C51507.dita"><linktext>Using Signals to Terminate Processes</linktext> </link> <link href="GUID-E65D91AE-482F-5592-B83C-0F29126C2EFA.dita"><linktext>Using Signals to Handle Exceptions</linktext> </link> </related-links></concept>
    44 </conbody><related-links>
       
    45 <link href="GUID-66C1493D-5B85-558A-9A39-454E6EBA307B.dita"><linktext>Signal Emulation
       
    46 on the Symbian Platform</linktext></link>
       
    47 <link href="GUID-186B9876-2A08-5F23-BB49-49EC34C51507.dita"><linktext>Using Signals
       
    48 to Terminate Processes</linktext></link>
       
    49 <link href="GUID-E65D91AE-482F-5592-B83C-0F29126C2EFA.dita"><linktext>Using Signals
       
    50 to Handle Exceptions</linktext></link>
       
    51 </related-links></concept>