Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] Add simple example how to use Vibe.d timers #434

Closed
ilya-stromberg opened this issue Dec 13, 2013 · 9 comments
Closed

[Documentation] Add simple example how to use Vibe.d timers #434

ilya-stromberg opened this issue Dec 13, 2013 · 9 comments

Comments

@ilya-stromberg
Copy link
Contributor

See also http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/8516/

s-ludwig added a commit that referenced this issue Dec 13, 2013
@s-ludwig
Copy link
Member

Is the added unittest-example enough, or do you have something additional in mind?

@ilya-stromberg
Copy link
Contributor Author

Thanks for unittest example. It's good as very simple example.

Can we add a little more complex example for sleep and setTimer in vibe.d/examples/timer folder?

@s-ludwig
Copy link
Member

So what exactly are you after? Some kind of task interaction in a certain situation? I always looked at timers/sleep as something so simple that they are barely worth an example.

@ilya-stromberg
Copy link
Contributor Author

OK. Have we got unittest for sleep function?

@s-ludwig
Copy link
Member

I was seriously asking myself "WTF should an example for sleep show in addition to the obvious?". But there may be some value in showing how to specify the duration (e.g. 4.seconds()). Is that what you thought?

@etcimon
Copy link
Contributor

etcimon commented Dec 19, 2013

I think it would be useful to have an example that shows how sleep doesn't block other tasks.

handler(HTTPServerRequest req, HTTPServerResponse res){
    import std.conv;
    runTask( { foreach ( i ; 0..5) sleep(1.seconds), res.write("sleep #1 seconds: " ~ i.to!string); });
    foreach ( i ; 0...5 ) sleep(3.seconds), res.write("sleep #2 seconds: " ~ (i*3).to!string);
}

@ilya-stromberg
Copy link
Contributor Author

But there may be some value in showing how to specify the duration (e.g. 4.seconds()). Is that what you thought?

Yes, it is.

I think it would be useful to have an example that shows how sleep doesn't block other tasks.

Yes, it looks like a little more complex example that I wanted to see.

@s-ludwig
Copy link
Member

I think it would be useful to have an example that shows how sleep doesn't block other tasks.

Yes, it looks like a little more complex example that I wanted to see.

But then I'd have to add examples for each and every blocking function, to show that it doesn't block other tasks. I don't know, maybe half a sentence about in the description is clear enough? But in general this is a basic concept of the whole library, so I don't think repeating it all over again for every function is a good idea.

@ilya-stromberg
Copy link
Contributor Author

OK, OK. As I said, simple unittest should be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants