Results 1 to 3 of 3

Thread: calling a function on a event timer in KOS  1.3?

                  
   
  1. #1
    DCEmu Coder GPF's Avatar
    Join Date
    Apr 2004
    Location
    Texas
    Age
    50
    Posts
    796
    Rep Power
    72

    Default calling a function on a event timer in KOS  1.3?

    was wondering if there is anything in KOS that would call a function every couple of seconds. Kind of like event timer.

    if so some example code, or some pointer in the right direction.

    I have used windows timers before, and I think I kind of understand alarms and signals on unix. but can't figure out how to do it with KOS.

    Thanks,
    Troy

  2. #2
    Dream Coder
    Join Date
    Apr 2004
    Location
    Miami, FL
    Age
    36
    Posts
    4,675
    Rep Power
    50

    Default Re: calling a function on a event timer in KOS ?

    you could have something in the main loop of a program that checks if the proper amount of time has elapsed and calls the function.

    alternatively you could set up a threading system where your event check is in a seperate thread from the main code and runs in parallel to it. Anything like that would be really slow.
    If anyone is looking to buy, sell, trade games and support a developer directly at the same time, consider joining Goozex. Enjoy!

  3. #3
    DCEmu Coder GPF's Avatar
    Join Date
    Apr 2004
    Location
    Texas
    Age
    50
    Posts
    796
    Rep Power
    72

    Default Re: calling a function on a event timer in KOS *1.

    here is the psuedo code that I am trying to convert

    Code:
    void dowork(){ 
      // do most of the processing 
    } 
    
    void work(int i) { 
      // stuff 
      ualarm(counter, 0); 
      dowork(); 
      } 
    
    int go() { 
      signal(SIGALRM, work); 
      ualarm(delay, 0); 
    
      return 0; 
    } 
    
    int main(int argc, char *argv[]) { 
       
       go(); 
       while(going){ 
       process_input(); 
       } 
       return 0; 
    }
    I need a little help structuring it so that I can use threads if needed.

    Thanks,
    Troy

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •