Re: [AD] Get thread id

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Sure i know how a good thread safe function should be.As i said above
is not for my program, but from the discussion is seems that we are
trying to avoid something by saying that its "bad design / bad
practice".Yeah of course is bad bad bad bad very bad  think to call a
function from multiple threads if its not thread safe but by having a
thread id someone can assure this.Maybe there are other reasons for
someone to get a thread id (Nothings comes in mind though)

As i said, i am not dying for this function to be added.I though it
will be a nice addition that's the reason i created a patch.It can be
skipped though.


On Sat, Aug 18, 2012 at 3:13 AM, Thomas Fjellstrom
<tfjellstrom@xxxxxxxxxx> wrote:
> On Fri Aug 17, 2012, Thomas Fjellstrom wrote:
>> On Fri Aug 17, 2012, Dimitris Zenios wrote:
>> > Its not for my program but i think there are cases that you have to be
>> > sure that a function is not called from another thread other than the
>> > main.Also sanity checks etc.In my opinion i think is something good
>> > for the library to supply.If not possible at the moment or difficult
>> > to implement in a safe way then it can be skipped.
>>
>> Well generally you just don't call functions from multiple threads if they
>> shouldn't be called. If you do need/want to call the same function from
>> multiple threads, the code needs to be fully reentrant. Generally thats
>> done with locks/mutexes, or just not depending on global state or having
>> any race conditions (writing from two separate threads? reading from one
>> writing in the other?). (or fancy lockless algorithms)
>
> Derp moment. reentrant != thread safe. You want your code to be thread safe.
>
>> > On Sat, Aug 18, 2012 at 2:57 AM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
>> > > On Sat, 18 Aug 2012 02:43:06 +0300, Dimitris Zenios
>>
>> <dimitris.zenios@xxxxxxxxxx> wrote:
>> > >> >From my previous email. get thread id would be an easy way to check
>> > >> >if
>> > >>
>> > >> the function was called from the main thread or not.
>> > >
>> > > But why is your program designed like that?
>> > >
>> > > Peter
>> > >
>> > > -----------------------------------------------------------------------
>> > > -- ----- Live Security Virtual Conference
>> > > Exclusive live event will cover all the ways today's security and
>> > > threat landscape has changed and how IT managers can respond.
>> > > Discussions will include endpoint security, mobile security and the
>> > > latest in malware threats.
>> > > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ --
>> > > https://lists.sourceforge.net/lists/listinfo/alleg-developers
>> >
>> > -------------------------------------------------------------------------
>> > -- --- Live Security Virtual Conference
>> > Exclusive live event will cover all the ways today's security and
>> > threat landscape has changed and how IT managers can respond. Discussions
>> > will include endpoint security, mobile security and the latest in malware
>> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
> --
> Thomas Fjellstrom
> tfjellstrom@xxxxxxxxxx
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> --
> https://lists.sourceforge.net/lists/listinfo/alleg-developers




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/