Re: [Vala] Thread Support



2014-08-13 18:08 GMT-05:00 Jim Nelson <jim yorba org>:

On Wed, Aug 13, 2014 at 1:13 PM, Daniel Espinosa <esodan gmail com> wrote:

read_async.begin();


For the comment above, I think this form must be deprecated to add clear
meaning in Vala code for async functions, even the compiler must rise an
error when yield is used in unasync function.


It's not about readability, they are different ways of invoking the same
method.  The first (with "yield") can only be used within an async method.
 It means what it looks like, the caller will yield control to read_async()
until the call returns.  The second (with ".begin") can be called from any
method.  It initiates read_async() but returns immediately; you might think
of it as scheduling the call in the background and not waiting for it to
complete.  (You can pass a completion callback with .begin that is called
when finished.)

Then this is a bug in glib-2.0.vapi, because it seds:

[Deprecated (since = "2.32", replacement = "new Thread<T> ()")]
[CCode (simple_generics = true)]
public static unowned Thread<T> create<T> (ThreadFunc<T> func, bool
joinable) throws ThreadError;


I'm not sure what you're seeing there.  If you're using Vala 0.20, I would
recommend upgrading to at least the latest stable version (0.24).


These annotations makes to rise warning messages, suggesting to change your
code, but no prevent developer how to proceed.

Adding some more descriptions like add " and valac's --target-glib=2.32
flag"text to replacement attribute, in order to help developer how to
proceed. Is this description correct? developer must use --target-glib in
order to enable new features?


Warning from compiler must suggest to use this instead to just warn about
use implicit .begin is deprecated. Message could be:

"async functions should use attribute .begin or 'yield' modifier when it
is called"


You might try filing a ticket or, better yet, a patch.

-- Jim




-- 
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los
cuates: LIBRE)


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