Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed (Author was flagged for spam)

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

5
Efficient asynchronous programming -- search keywords/basic pointers (ha)/examples?
Post Flair (click to view more posts with a particular flair)
Post Body

Okay so I have no idea on how to word this correctly, and i wanted to maybe get some keywords or ideas or something to achieve what I want to achieve.

Here's what I want to do: - I want to be able to run a single function asynchronously, many times. - The function is fast enough where the overhead of creating a new thread would outweigh the advantage of running it asynchronously. - I don't want to use a loop-and-flag system like below, as it would cause the thread to hog up all the CPU time:

```c int thread (void * unused) { while (true) { while (run_thread == false); // wait until run_thread = true run_thread = false; // ... } }

// to call it: run_thread = true; ```

  • It'd be nice, but not necessary, to know when the function has completed later on in the program.
  • It is guaranteed that there won't be more than one instance of the asynchronous function running at once.

I'm using SDL 1.2 in this program so any SDL 1.2 stuff I can use (long story, but I could use SDL2 if it was an option, but it's not in this case,) but using external libraries is okay if necessary. Additionally, I'm using Linux so WinAPIs aren't an option, either.

Also, it's okay if it's a very hacky and convoluted solution, my code is already a mess.

Author
Account Strength
0%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
89,325
Link Karma
48,280
Comment Karma
38,812
Profile updated: 7 months ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago