Threads

42 views
Skip to first unread message

César

unread,
Feb 13, 2015, 11:18:09 AM2/13/15
to yeti...@googlegroups.com

Hi Yeti seems to be a good candidate for concurrent programming, can i safetly use all those immutable stuff in a multithreading environment?, also seems that there is not language level constructs to handle synchronization (like java synchronized keyword), that is the recommended way to handle this in yeti?

César.

César

unread,
Feb 13, 2015, 11:29:01 AM2/13/15
to yeti...@googlegroups.com
a typo sorry, i mean, What is the recommended way to handle this in yeti?

Madis

unread,
Feb 13, 2015, 8:04:51 PM2/13/15
to yeti...@googlegroups.com
Yes you should be fine with immutable data structures when multithreading.

Note that in some cases there are read-only views of mutable structures
and the type itself won't tell it. For example:

http://dot.planet.ee/yeti/docs/latest/yeti.lang.std.html#tail

From the documentation:

"Notes
The tail function can be used on array. In this case a list view of array
is returned, consisting of all elements starting from index 1 (subsequent
applications of tail give views with increased start index). As the list
view still references to the original array, it will change when the array
is modified (use copy function to get an independent copy)."

Using those views without synchronization can obviously give undetermined
results, when some thread modifies the original array.

Another thing is that the standard library don't include immutable tree
maps currently.

chrisichris

unread,
Feb 14, 2015, 9:27:58 AM2/14/15
to yeti...@googlegroups.com
 also seems that there is not language level constructs to handle synchronization (like java synchronized keyword), that is the recommended way to handle this in yeti?

There is the 'synchronized' function which does the same as the java synchronized keyword (AFAIK it is also optimized by the compiler). http://dot.planet.ee/yeti/docs/latest/yeti.lang.std.html#synchronized

See also the 'atomic' funciton in the std module and finally you can also use all the java.util.concurrent apis.

Christian 

César

unread,
Feb 14, 2015, 10:00:09 PM2/14/15
to yeti...@googlegroups.com
Thanks for all the advices.

César.


Reply all
Reply to author
Forward
0 new messages