Boost logo

Boost :

From: Rene Rivera (grafikrobot_at_[hidden])
Date: 2007-04-20 19:41:28


Steven Watanabe wrote:
> struct tag {};
>
> void f(int (&array)[100][3], unsigned key_index) {
> assert(key_index < 3);
> std::qsort(array,100,sizeof(int[3]),
> make_c_function<tag,void(const void*,const void*)>(
> ll::static_cast_<const int*>(_1)[key_index] <
> ll::static_cast_<const int*>(_1)[key_index]));
> }

struct tag
{
   boost::mutex lock;
};

tag tag_;

void f(int (&array)[100][3], unsigned key_index)
{
   assert(key_index < 3);
   boost::mutex::scoped_lock l(tag_.lock);
   std::qsort(array,100,sizeof(int[3]),
     make_c_function<tag,void(const void*,const void*)>(
       ll::static_cast_<const int*>(_1)[key_index] <
       ll::static_cast_<const int*>(_1)[key_index]));
}

Not that the use case makes any sense to me :-( So I'm still guessing as
to what you want to achieve with thread safety here.

PS... This thread reminds me of the ##c++ irc conversations.

-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk