1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Set Timer a function callback

Discussion in 'C' started by davidhai, Sep 29, 2008.

  1. davidhai

    davidhai New Member

    Joined:
    Sep 29, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hi everybody,

    I am trying to switch from a multicast address to another multicast address. On the bottom of ExecSwitchStreams that perform switch, I want to register a function (ExecSwitchStreamsBack ) so that the program will auto call to after t_time seconds. ExecSwitchStreamsBack will switch back to old multicast address.

    Code:
    static void ExecSwitchStreams(input_thread_t *p_input, char *p_new_server, int64_t t_time)
    {		
    	InputClean( p_input, &p_input->input );		
    	
    	input_source_t *other_input = &p_input->input;		
     
    	   /* Create the stream_t */
    	   other_input->p_stream = streamAccessNew( other_input->p_access, p_new_server, MY_FALSE );
       
    		RegisterTimer ( t_time, p_old_server, ExecSwitchStreamsBack) //  Function to register call ExecSwitchStreamsBack after t_time seconds 
    																	// p_old_server is a parameter for ExecSwitchStreamsBack 
      
    }
    
    static void ExecSwitchStreamsBack(char *p_old_server )
    {
    	 // code
    }
    
    How can I implement the RegisterTimer like that?

    Please give me any ideas to implement this function. Many thanks
     
  2. davidhai

    davidhai New Member

    Joined:
    Sep 29, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    If anybody knows about this problem, please help me to solve it.
     
  3. oogabooga

    oogabooga New Member

    Joined:
    Jan 9, 2008
    Messages:
    115
    Likes Received:
    11
    Trophy Points:
    0
    What operating system?
    (Looks like unix. What is the function for creating a timer?)
    Where is p_old_server coming from.
     
  4. davidhai

    davidhai New Member

    Joined:
    Sep 29, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    This is a program that it can run on Unix, Window,Mac Os. On window, I use cygwin to compile source. I have use <time.h> library in my source code.

    p_old_server is a static variable that is stored before performing switch.
     

Share This Page