Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Question on return value of al_create_thread

This thread is locked; no one can reply to it. rss feed Print
Question on return value of al_create_thread
Edgar Reynaldo
Major Reynaldo
May 2007
avatar

l j
Member #10,584
January 2009
avatar

I believe it's just whatever you want to return.
To actually get a return value you'd need to use al_join_thread.

GullRaDriel
Member #3,861
September 2003
avatar

Your supposed to return the thread id so another thread can manage it and eventually stall/cancel it.

Edit: seeing the prototype and the definition, I think the documentation is somewhat wrong.

// does not really return 'true' but a valid ALLEGRO_THREAD or NULL; imho
ALLEGRO_THREAD *al_create_thread(void *(*proc)(ALLEGRO_THREAD *thread, void *arg), void *arg)

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Thomas Fjellstrom
Member #476
June 2000
avatar

Your supposed to return the thread id so another thread can manage it and eventually stall/cancel it.

Once you return from your function, the thread is done. So that wouldn't really do what you think :P

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

Edit: seeing the prototype and the definition, I think the documentation is somewhat wrong.

This discussion is about the return value of the proc callback (i.e., the thread function), not the return value of al_create_thread() (which is what you are describing).

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Spawn a new thread which begins executing proc. The new thread is passed its own thread handle and the value arg.

Returns true if the thread was created, false if there was an error.

Well, it doesn't actually begin executing proc until you call al_start_thread. And it doesn't return true, it's a pointer to a newly created ALLEGRO_THREAD or zero (null) like Gull said.

It would sound better like :

Create a new thread which will run proc later when you call al_start_thread. The thread is passed its own thread handle and the value arg.

Returns a pointer to a newly created ALLEGRO_THREAD, or NULL if there was an error.

How does that sound?

GullRaDriel
Member #3,861
September 2003
avatar

I feel understood. Thanks Edgar. The two other are just reluctant trolls ;-p

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Thomas Fjellstrom
Member #476
June 2000
avatar

I feel understood. Thanks Edgar. The two other are just reluctant trolls ;-p

Actually, I just didn't really understand what you were trying to say.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

l j
Member #10,584
January 2009
avatar

Apparently I'm incapable of parsing human languages.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Thomas Fjellstrom
Member #476
June 2000
avatar

To be honest, I had assumed Gull was talking about the user function, because you (Edgar) were.

I don't think that's an entirely unreasonable thing to think.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Elias
Member #358
May 2000

What format are Allegro's docs in? I will submit a patch if its not too complex.

The documentation is written in markdown (processed by pandoc). This particular function is documented here: http://sourceforge.net/p/alleg/allegro/ci/5.1/tree/docs/src/refman/threads.txt

It's just a simple wiki format, so you should be able to create a patch without actually installing pandoc.

--
"Either help out or stop whining" - Evert

Go to: