src/hotspot/os/linux/waitBarrier_linux.hpp
author alanb
Thu, 21 Mar 2019 08:41:10 +0000
branchniosocketimpl-branch
changeset 57275 222fa5ed1c91
parent 53254 47bc06170313
permissions -rw-r--r--
Add @systemProperty ref to system property to configure old impl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53254
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     1
/*
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     4
 *
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     8
 *
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    13
 * accompanied this code).
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    14
 *
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    18
 *
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    21
 * questions.
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    22
 *
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    23
 */
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    24
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    25
#ifndef OS_LINUX_WAITBARRIER_LINUX_HPP
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    26
#define OS_LINUX_WAITBARRIER_LINUX_HPP
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    27
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    28
#include "memory/allocation.hpp"
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    29
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    30
class LinuxWaitBarrier : public CHeapObj<mtInternal> {
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    31
  volatile int _futex_barrier;
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    32
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    33
  // Prevent copying and assignment of LinuxWaitBarrier instances.
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    34
  LinuxWaitBarrier(const LinuxWaitBarrier&);
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    35
  LinuxWaitBarrier& operator=(const LinuxWaitBarrier&);
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    36
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    37
 public:
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    38
  LinuxWaitBarrier() : _futex_barrier(0) {};
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    39
  ~LinuxWaitBarrier() {};
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    40
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    41
  const char* description() { return "futex"; }
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    42
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    43
  void arm(int barrier_tag);
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    44
  void disarm();
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    45
  void wait(int barrier_tag);
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    46
};
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    47
47bc06170313 8214271: Fast primitive to wake many threads
rehn
parents:
diff changeset
    48
#endif // OS_LINUX_WAITBARRIER_LINUX_HPP