GThreads and GThreadPool help for a dummy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm not really experienced when it comes to threading, and GThreads is
the thing I want to use, since (I assume) it's quite portable.

I have a function that returns a gfloat and I call the function
sequentially and accumulate the total.
Like this:

/* My sequential pseudo code */
data_t data[N_DATAPOINTS];
gfloat tot_err = 0.0f;
guint i;

fill_the_data_array( data );

for ( i = 0; i < N_DATAPOINTS; i++ )
    tot_err += calc_error( &data[i] );

/* End of my sequential pseudo code */

I have the impression that this should be rather simple to thread
for-loop. Since addition is commutative, I may not even need a mutex
for the tot_err variable.

Can anyone point me in the right direction?

-Øystein
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux