ホーム › System.Threading › EnterSynchronizationBarrier
EnterSynchronizationBarrier
関数同期バリアに到達し全スレッドの到達を待機する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL EnterSynchronizationBarrier(
SYNCHRONIZATION_BARRIER* lpBarrier,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpBarrier | SYNCHRONIZATION_BARRIER* | inout |
| dwFlags | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL EnterSynchronizationBarrier(
SYNCHRONIZATION_BARRIER* lpBarrier,
DWORD dwFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool EnterSynchronizationBarrier(
IntPtr lpBarrier, // SYNCHRONIZATION_BARRIER* in/out
uint dwFlags // DWORD
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function EnterSynchronizationBarrier(
lpBarrier As IntPtr, ' SYNCHRONIZATION_BARRIER* in/out
dwFlags As UInteger ' DWORD
) As Boolean
End Function' lpBarrier : SYNCHRONIZATION_BARRIER* in/out
' dwFlags : DWORD
Declare PtrSafe Function EnterSynchronizationBarrier Lib "kernel32" ( _
ByVal lpBarrier As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EnterSynchronizationBarrier = ctypes.windll.kernel32.EnterSynchronizationBarrier
EnterSynchronizationBarrier.restype = wintypes.BOOL
EnterSynchronizationBarrier.argtypes = [
ctypes.c_void_p, # lpBarrier : SYNCHRONIZATION_BARRIER* in/out
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
EnterSynchronizationBarrier = Fiddle::Function.new(
lib['EnterSynchronizationBarrier'],
[
Fiddle::TYPE_VOIDP, # lpBarrier : SYNCHRONIZATION_BARRIER* in/out
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn EnterSynchronizationBarrier(
lpBarrier: *mut SYNCHRONIZATION_BARRIER, // SYNCHRONIZATION_BARRIER* in/out
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool EnterSynchronizationBarrier(IntPtr lpBarrier, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_EnterSynchronizationBarrier' -Namespace Win32 -PassThru
# $api::EnterSynchronizationBarrier(lpBarrier, dwFlags)#uselib "KERNEL32.dll"
#func global EnterSynchronizationBarrier "EnterSynchronizationBarrier" sptr, sptr
; EnterSynchronizationBarrier varptr(lpBarrier), dwFlags ; 戻り値は stat
; lpBarrier : SYNCHRONIZATION_BARRIER* in/out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global EnterSynchronizationBarrier "EnterSynchronizationBarrier" var, int ; res = EnterSynchronizationBarrier(lpBarrier, dwFlags) ; lpBarrier : SYNCHRONIZATION_BARRIER* in/out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global EnterSynchronizationBarrier "EnterSynchronizationBarrier" sptr, int ; res = EnterSynchronizationBarrier(varptr(lpBarrier), dwFlags) ; lpBarrier : SYNCHRONIZATION_BARRIER* in/out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL EnterSynchronizationBarrier(SYNCHRONIZATION_BARRIER* lpBarrier, DWORD dwFlags) #uselib "KERNEL32.dll" #cfunc global EnterSynchronizationBarrier "EnterSynchronizationBarrier" var, int ; res = EnterSynchronizationBarrier(lpBarrier, dwFlags) ; lpBarrier : SYNCHRONIZATION_BARRIER* in/out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL EnterSynchronizationBarrier(SYNCHRONIZATION_BARRIER* lpBarrier, DWORD dwFlags) #uselib "KERNEL32.dll" #cfunc global EnterSynchronizationBarrier "EnterSynchronizationBarrier" intptr, int ; res = EnterSynchronizationBarrier(varptr(lpBarrier), dwFlags) ; lpBarrier : SYNCHRONIZATION_BARRIER* in/out -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procEnterSynchronizationBarrier = kernel32.NewProc("EnterSynchronizationBarrier")
)
// lpBarrier (SYNCHRONIZATION_BARRIER* in/out), dwFlags (DWORD)
r1, _, err := procEnterSynchronizationBarrier.Call(
uintptr(lpBarrier),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction EnterSynchronizationBarrier(
lpBarrier: Pointer; // SYNCHRONIZATION_BARRIER* in/out
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'KERNEL32.dll' name 'EnterSynchronizationBarrier';result := DllCall("KERNEL32\EnterSynchronizationBarrier"
, "Ptr", lpBarrier ; SYNCHRONIZATION_BARRIER* in/out
, "UInt", dwFlags ; DWORD
, "Int") ; return: BOOL●EnterSynchronizationBarrier(lpBarrier, dwFlags) = DLL("KERNEL32.dll", "bool EnterSynchronizationBarrier(void*, dword)")
# 呼び出し: EnterSynchronizationBarrier(lpBarrier, dwFlags)
# lpBarrier : SYNCHRONIZATION_BARRIER* in/out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。