punchclock

Make sure your asynchronous operations show up to work on time

MIT License

Stars
260
Committers
18

Bot releases are hidden (Show)

punchclock - 2.0.0

Published by ghuntley almost 8 years ago

Punchclock is the low-level scheduling and prioritization library used by Fusillade to orchestrate pending concurrent operations.

What even does that mean?

Ok, so you've got a shiny mobile phone app and you've got async/await. Awesome! It's so easy to issue network requests, why not do it all the time? After your users one-🌟 you for your app being slow, you discover that you're issuing way too many requests at the same time.

Then, you try to manage issuing less requests by hand, and it becomes a spaghetti mess as different parts of your app reach into each other to try to
figure out who's doing what. Let's figure out a better way.

So many words, gimme the examples

var wc = new WebClient();
var opQueue = new OperationQueue(2 /*at a time*/);

// Download a bunch of images
var foo = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/foo.jpg", "foo.jpg"));
var bar = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/bar.jpg", "bar.jpg"));
var baz = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/baz.jpg", "baz.jpg"));
var bamf = opQueue.Enqueue(1, 
    () => wc.DownloadFile("https://example.com/bamf.jpg", "bamf.jpg"));

// We'll be downloading the images two at a time, even though we started 
// them all at once
await Task.WaitAll(foo, bar, baz, bamf);

Now, in a completely different part of your app, if you need something right
away, you can specify it via the priority:

// This file is super important, we don't care if it cuts in line in front
// of some images or other stuff
var wc = new WebClient();
await opQueue.Enqueue(10 /* It's Important */, 
    () => wc.DownloadFileTaskAsync("http://example.com/cool.txt", "./cool.txt"));

As part of this release we had 4 issues closed.

Breaking change

  • #16 implemented netstandard v1.0 and upgraded to System.Reactive 3.0

Bug

  • #15 added missing bool in equality comparison

Improvements

  • #19 implemented continuous integration
  • #18 added coc & github issues/pr templates

Where to get it

You can download this release from nuget.org

punchclock - Punchclock 1.2.0

Published by anaisbetts about 10 years ago

What's New

  • Update PCL to support Windows Phone 8.1 Universal apps (#11, thanks @prasannavl!)
punchclock - Punchclock 1.1.1

Published by anaisbetts over 10 years ago

What's New

Bug Fixes

  • Update to latest Rx
  • Fix the portable library path to be compatible with WPA81 Portable Libraries
punchclock - Punchclock 1.1.0

Published by anaisbetts almost 11 years ago

What's New

Adjusting maximum concurrent

Thanks to @pedroreys, Punchclock now allows adjusting the maximum amount of concurrent items. If the limit is lowered, in-flight operations are not canceled, the limit only affects items dispatched in the future.

Bug Fixes

  • NuGet package now includes a dependency to Rx (#7)
  • Passing in null for the key now does not limit concurrency based on the key
punchclock - Punchclock 1.0.1

Published by anaisbetts almost 11 years ago

What's New

New Task Methods

  • Added new overloads of Enqueue to omit optional parameters, thanks @TheAngryByrd!

Misc

  • If an operation is queued but the operation is canceled before it is scheduled, the calculation function is no longer called
punchclock - Punchclock 1.0.0

Published by anaisbetts about 11 years ago

Initial Release