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

Comments

Projects
None yet
3 participants

s-ludwig added a commit that referenced this issue Dec 13, 2013

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Dec 18, 2013

Member

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

Member

s-ludwig commented Dec 18, 2013

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

@ilya-stromberg

This comment has been minimized.

Show comment
Hide comment
@ilya-stromberg

ilya-stromberg Dec 18, 2013

Contributor

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?

Contributor

ilya-stromberg commented Dec 18, 2013

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

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Dec 18, 2013

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.

Member

s-ludwig commented Dec 18, 2013

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

This comment has been minimized.

Show comment
Hide comment
@ilya-stromberg

ilya-stromberg Dec 18, 2013

Contributor

OK. Have we got unittest for sleep function?

Contributor

ilya-stromberg commented Dec 18, 2013

OK. Have we got unittest for sleep function?

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Dec 18, 2013

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?

Member

s-ludwig commented Dec 18, 2013

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

This comment has been minimized.

Show comment
Hide comment
@etcimon

etcimon Dec 19, 2013

Contributor

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);
}
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

This comment has been minimized.

Show comment
Hide comment
@ilya-stromberg

ilya-stromberg Dec 19, 2013

Contributor

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.

Contributor

ilya-stromberg commented Dec 19, 2013

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

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Dec 20, 2013

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.

Member

s-ludwig commented Dec 20, 2013

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

This comment has been minimized.

Show comment
Hide comment
@ilya-stromberg

ilya-stromberg Dec 20, 2013

Contributor

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

Contributor

ilya-stromberg commented Dec 20, 2013

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

@s-ludwig s-ludwig closed this in 0a778a5 Dec 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment