Commit 239be903 authored by Erick Hitter's avatar Erick Hitter
Browse files

Allow certain events to run concurrently if scheduled that way

Most events, due to alloptions inconsistencies, cannot run in parallel. Certain events, however, may be acceptable.

Fixes #106.
parent 024c45b1
...@@ -281,8 +281,17 @@ class Events extends Singleton { ...@@ -281,8 +281,17 @@ class Events extends Singleton {
* @return bool * @return bool
*/ */
private function can_run_event( $event ) { private function can_run_event( $event ) {
// Limit to one concurrent execution of a specific action // Limit to one concurrent execution of a specific action by default
if ( ! Lock::check_lock( $this->get_lock_key_for_event_action( $event ), 1, JOB_LOCK_EXPIRY_IN_MINUTES * \MINUTE_IN_SECONDS ) ) { $limit = 1;
$concurrency_whitelist = apply_filters( 'a8c_cron_control_concurrent_event_whitelist', array(), $event );
if ( isset( $concurrency_whitelist[ $event->action ] ) ) {
$limit = absint( $concurrency_whitelist[ $event->action ] );
$limit = min( $limit, JOB_CONCURRENCY_LIMIT );
}
if ( ! Lock::check_lock( $this->get_lock_key_for_event_action( $event ), $limit, JOB_LOCK_EXPIRY_IN_MINUTES * \MINUTE_IN_SECONDS ) ) {
return false; return false;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment