Hi.
I have the following scenario. DeviceIOControl calls are received (from a
queue with parallel dispatch). The work to be done can block so I am
creating a workitem and then returning from EvtIoDeviceControl(). The
workitem does the work and completes the request. If a second IO control is
recieved whilst the first workitem is still busy, i create a new workitem
etc..
Question 1: Is it ok to dynamically create multiple workitems? Is there a
way of destroying them after use? Or would it be better to just create a
number of them in EvtDeviceAdd and then just keep track of the ones in use?
The workitem is created as follows:
WDF_OBJECT_ATTRIBUTES_INIT( &IOCTLWorkItemAttributes );
WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE( &IOCTLWorkItemAttributes,
IOCTL_WORKITEM_EXTENSION );
IOCTLWorkItemAttributes.ParentObject = device;
WDF_WORKITEM_CONFIG_INIT( &IOCTLWorkitemConfig, PCIMotionEvtIOCTLWorkItem );
IOCTLWorkitemConfig.AutomaticSerialization = FALSE;
status = WdfWorkItemCreate( &IOCTLWorkitemConfig, &IOCTLWorkItemAttributes,
&hIOCTLWorkItem);
Question 2: Does each workitem created get a unique context space, or do
they all share the same context?
Thanks in advance.
Laurence