Re: [Vala] Thread Support



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).

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


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