5th Job and Process Pool (2)

Source: Internet
Author: User

5.6 Job Object events and completion ports

(1) associating the Job object with the completion port object

Jobobject_associate_completion_port JOACP;

JOACP. Completionkey = hJob1; can be used to identify any unique value of a Job Object , where its handle is taken

JOACP. Completionport = HIOCP; handle to completion port

Setinformationjobobject (Hjob,jobobjectassociatecompletionportinformation,

&joacp,sizeof (JOACP));

(2) creates a thread that passes the completion port object as a parameter to the thread function. and GetQueuedCompletionStatus to wait for a notification event for the Job object.

Parameters

Describe

HIOCP

Handle of the completion port object to get the event

Pnumbytestransferred

Event ID to wait for

"Events related to Job Object"

①job_object_msg_active_process_limit: The number of active processes in the Job object reaches the limit notification

②Job_object_msg_active_process_zero: Notification when there are currently no active processes in the Job Object

③job_object_msg_end_of_job_time: The Job Object exhausts the specified time period notification. However, the process does not automatically terminate. You can set a new time limit to allow continuation, or call Terminatejobobject to terminate the process.

④job_object_msg_job_memory_limit: The Job Object exhausts the specified memory notification while giving the process ID

"Process-related events"

①job_object_msg_new_process: Notifies when a new process joins the Job object and gives the process ID.

②job_object_msg_exit_process: Notifies when the process exits gracefully and gives the process ID.

③job_object_msg_abnormal_exit_process: Notification when the process exits unexpectedly and gives the process ID

④job_object_msg_end_of_process_time: Process runs out of time notifications, process terminates, and process ID is given

⑤job_object_msg_process_memory_limit: The process consumes memory up to the time limit notification, and the process IDis given.

pcompletionkey

Specifies the handle of the job object that triggered the event ( )

poverlapped

In a job event, The value represents which id .

Dwmilliseconds

Used to specify when the caller waits for the port to complete

Note:

① the state of a Job object becomes self-triggering when the time to allocate a job expires, not when all processes end.

② by default, when the job time expires, all its processes are automatically terminated, so the job_object_msg_end_of_job_timeis not delivered. If you just want to send the notification to the application and let the application kill the process by itself, you can do the following:

  // Create a struct and fill in the structure with the actions to take at the end of the JOb

jobobject_end_of_job_time_information joeojti;

Joeojti. Endofjobtimeaction = Job_object_post_at_end_of_job; // deliver notifications instead of "kill" the process. When the job is created, the default value is job_object_terminate_at_end_of_job;

 // tell the Job object what to take when the job time expires

setinformationjobobject (hjob,jobobjectendofjobtimeinformation,

&joeojti,sizeof (JOEOJTI));

"Jobio" uses completion ports for process management

5th Job and Process Pool (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.