EdColeman commented on a change in pull request #2324: URL: https://github.com/apache/accumulo/pull/2324#discussion_r734603466
########## File path: server/base/src/main/java/org/apache/accumulo/server/conf/store/impl/ReadyMonitor.java ########## @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.server.conf.store.impl; + +import java.util.StringJoiner; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.ReentrantLock; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides a barrier to block operations until a resource signals that it is ready. This class + * encapsulates a wait / notify operation using a lock and condition. Instances are initialized with + * the resource unavailable - call {@link #setReady()} when the resource is available + */ +public class ReadyMonitor { Review comment: Yes, but I could not find a fit, but maybe I missed something? It really functions as a Barrier, but the standard concurrent classes all seemed to require knowing external information such as the number of threads. I also looked at Phaser, which is really close, but I could not see how to have: - Be reusable. - Block a variable number of threads without knowing how many It also seems like a Semiphone, but in reverse. Instead of a number of permits, there is one. As long as someone holds it, everyone can continue. If it is released / available, then wait. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
