Off the top of my head, you can use it to attempt to push work to the worker pool in order to get better parallelization and if that fails enqueue it for your backup dedicated worker thread, or process it in the current thread and starve the caller.
You handle the failure the way you handle any resource allocation failure - either fail the request or fall back to using backup resources (which may involve waiting for them to become available and may be slower)
-p
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, April 10, 2014 9:28 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] IoTryQueueWorkItem
Allow priority DPC? Anton, WTF is wrong with you tonight?
I am just considering the situation when you call IoTryQueueWorkItem()from DPC routine and your call fails because, say, all threads that process workitems are currently blocked. How are you going to deal with this situation if you have to enqueue your workitem no matter what??? The only possible solution seems to be to queue a low-priority DPC (i.e. the one that gets executed when CPU has nothing else to do at the moment) and to try to enqueue your workitem again from this DPC routine…
As long as you use IoQueueWorkItem() or IoQueueWorkItemEx() you will never encounter this situation - these functions are void and, hence, cannot fail. However, the name TryXXXX strongly suggests that your call may fail. My point is that allowing a routine that is meant to queue a workitem fail does not seem to be reasonable at all, which makes me wonder about the purpose of IoTryQueueWorkItem(), in the first place…
Anton Bassov
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer