See also #964 <https://github.com/JuliaLang/julia/issues/964>
Ivar kl. 11:48:47 UTC+2 mandag 16. juni 2014 skrev Cristóvão Duarte Sousa følgende: > > While I've been used to use threads (heavyweight ones) everywhere in my > projects, I'm starting to understand and really love the coroutines. > They make lot more sense in many applications where I was used to use > threads having to care about preemption and to use mutexes to avoid > inconsistent shared memory states. > > > Maybe this is not the best way to do it, but I'm sharing data between > tasks using global consts. > With mutables it guarantees type stability and good type inference inside > the task functions, however, if I need to share a single Bool state it > can't be const. > On the other hand, if I make it not const then there will be no type > stability with regards to that variable and type inference will not work. > > I've found out that I was able to create 0-dimensional arrays to box a > single immutable element (in global scope): > const flag = Array(Bool) > and then use it inside tasks as: > flag[] = true > ...... > if flag[] ..... > > I tend to read the [] as the C dereference operator. > > My question is: is this a reasonable use of this feature? > > >
