Skip to content

Instantly share code, notes, and snippets.

@JayBeavers
Created August 31, 2012 14:41
Show Gist options
  • Save JayBeavers/3553827 to your computer and use it in GitHub Desktop.
Save JayBeavers/3553827 to your computer and use it in GitHub Desktop.
Contents removed, pull request submitted in place of this prototype
We couldn’t find any files to show.
@JayBeavers
Copy link
Author

uv_work_queue is a 'simple as possible' repro of the out of order problem that occurs when using uv_queue_work to post data to be background processed. When you run it you will see Out of Order messages in the console.

uv_thread is a rewrite that uses a mutex locked FIFO queue to submit the data to be processed and a dedicated background thread to service the queue in order. When you run it no Out of Order messages are written.

@JayBeavers
Copy link
Author

Updated the design so that uv_work_t is used for both thread and queue samples and using the uv_default_loop for calling after_work_cb from background thread -- this keeps the node-serial write callback on the expected thread.

@JayBeavers
Copy link
Author

usleep is not platform agnostic and I haven't found a libuv equivalent of usleep(...). They added uv_sleep to their test harness, looks like this will need to be IFDEF'd.

@JayBeavers
Copy link
Author

Swapped out ngx_queue_t, the standard libuv queuing implementation, for stl queue

@JayBeavers
Copy link
Author

Switched from mutex to semaphore per advice on #libuv

@JayBeavers
Copy link
Author

Contents removed as a pull request for the full fix is now in place.

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