Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 60331 invoked from network); 15 Apr 2011 11:42:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Apr 2011 11:42:14 -0000 Received: (qmail 48481 invoked by uid 500); 15 Apr 2011 11:42:14 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 48435 invoked by uid 500); 15 Apr 2011 11:42:13 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 48428 invoked by uid 99); 15 Apr 2011 11:42:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Apr 2011 11:42:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Apr 2011 11:42:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A2AFB2388A1C; Fri, 15 Apr 2011 11:41:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1092669 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ java/org/apache/commons/runtime/platform/unix/ java/org/apache/commons/runtime/platform/windows/ native/ native/os/unix/ native/os/win32/ Date: Fri, 15 Apr 2011 11:41:45 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110415114145.A2AFB2388A1C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Fri Apr 15 11:41:44 2011 New Revision: 1092669 URL: http://svn.apache.org/viewvc?rev=1092669&view=rev Log: Add process Mutex stubs Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexType.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/FcntlMutex.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutex.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutex.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutexImpl.java (with props) commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c (with props) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties?rev=1092669&r1=1092668&r2=1092669&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/LocalStrings.properties Fri Apr 15 11:41:44 2011 @@ -15,3 +15,4 @@ os.ENOTIMPL=Apache Commons Runtime does not support this operating system os.EVERSION=Apache Commons Runtime does not support this operating system version +mutextype.EINVAL=Invalid MutexType enum initializer ({0}) Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,51 @@ +/* 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.commons.runtime; + +import org.apache.commons.runtime.exception.SystemException; + +/** + * Mutex class. + *

+ *

+ * + * @since Runtime 1.0 + */ +public abstract class Mutex +{ + + protected Mutex() + { + // No Instance + } + + private static final MutexImpl impl; + private static native MutexImpl impl0() + throws OutOfMemoryError; + + static { + impl = impl0(); + } + + protected String name; + protected boolean owner; + + public static final MutexImpl getImpl() + { + return impl; + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,53 @@ +/* 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.commons.runtime; + +import org.apache.commons.runtime.exception.AlreadyExistsException; +import org.apache.commons.runtime.exception.NoSuchObjectException; +import org.apache.commons.runtime.exception.NotImplementedException; +import org.apache.commons.runtime.exception.SystemException; + +/** + * MutexImpl class. + *

+ *

+ * + * @since Runtime 1.0 + */ +public abstract class MutexImpl +{ + + protected MutexImpl() + { + // No Instance + } + + public abstract Mutex create(MutexType type, String name) + throws IllegalAccessException, + IllegalArgumentException, + AlreadyExistsException, + NotImplementedException, + SystemException; + + public abstract Mutex open(MutexType type, String name) + throws IllegalAccessException, + IllegalArgumentException, + NoSuchObjectException, + NotImplementedException, + SystemException; + +} + Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexType.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexType.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexType.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexType.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,55 @@ +/* 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.commons.runtime; + +/** + * Determines the type of process Mutex + */ +public enum MutexType +{ + /** Default platfrom Mutex type. */ + DEFAULT( 0), + /** POSIX semaphore process-based locking. */ + POSIXSEM( 1), + /** System V Semaphores. */ + SYSVSEM( 2), + /** fcntl() locking. */ + FCNTL( 3); + + + private int value; + private MutexType(int v) + { + value = v; + } + + public int valueOf() + { + return value; + } + + public static MutexType valueOf(int value) + throws IllegalArgumentException + { + for (MutexType e : values()) { + if (e.value == value) + return e; + } + throw new IllegalArgumentException(Local.sm.get("mutextype.EINVAL", value)); + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexType.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/FcntlMutex.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/FcntlMutex.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/FcntlMutex.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/FcntlMutex.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,51 @@ +/* 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.commons.runtime.platform.unix; + +import org.apache.commons.runtime.Mutex; +import org.apache.commons.runtime.Status; +import org.apache.commons.runtime.exception.AlreadyExistsException; +import org.apache.commons.runtime.exception.NoSuchObjectException; +import org.apache.commons.runtime.exception.NotImplementedException; +import org.apache.commons.runtime.exception.ClosedDescriptorException; +import org.apache.commons.runtime.exception.SystemException; + +/** + * FcntlMutex class. + *

+ *

+ * + * @since Runtime 1.0 + */ +final class FcntlMutex extends Mutex +{ + + private FcntlMutex() + { + // No Instance + } + + public FcntlMutex(final String name, boolean owner) + throws IllegalAccessException, + IllegalArgumentException, + AlreadyExistsException, + NotImplementedException, + SystemException + { + this.owner = true; + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/FcntlMutex.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutex.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutex.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutex.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutex.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,51 @@ +/* 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.commons.runtime.platform.unix; + +import org.apache.commons.runtime.Mutex; +import org.apache.commons.runtime.Status; +import org.apache.commons.runtime.exception.AlreadyExistsException; +import org.apache.commons.runtime.exception.NoSuchObjectException; +import org.apache.commons.runtime.exception.NotImplementedException; +import org.apache.commons.runtime.exception.ClosedDescriptorException; +import org.apache.commons.runtime.exception.SystemException; + +/** + * PosixMutex class. + *

+ *

+ * + * @since Runtime 1.0 + */ +final class PosixMutex extends Mutex +{ + + private PosixMutex() + { + // No Instance + } + + public PosixMutex(final String name, boolean owner) + throws IllegalAccessException, + IllegalArgumentException, + AlreadyExistsException, + NotImplementedException, + SystemException + { + this.owner = true; + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutex.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,89 @@ +/* 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.commons.runtime.platform.unix; + +import org.apache.commons.runtime.Mutex; +import org.apache.commons.runtime.MutexImpl; +import org.apache.commons.runtime.MutexType; +import org.apache.commons.runtime.exception.AlreadyExistsException; +import org.apache.commons.runtime.exception.NoSuchObjectException; +import org.apache.commons.runtime.exception.NotImplementedException; +import org.apache.commons.runtime.exception.SystemException; + +/** + * Posix MutexImpl class. + *

+ *

+ * + * @since Runtime 1.0 + */ +final class PosixMutexImpl extends MutexImpl +{ + + public PosixMutexImpl() + { + // No Instance + } + + private static native int getdefault0(); + private static final MutexType mtype; + static + { + mtype = MutexType.valueOf(getdefault0()); + } + + public Mutex create(MutexType type, String name) + throws IllegalAccessException, + IllegalArgumentException, + AlreadyExistsException, + NotImplementedException, + SystemException + { + if (type == MutexType.DEFAULT) + type = mtype; + switch (type) { + case POSIXSEM: + return new PosixMutex(name, true); + case SYSVSEM: + return new SysVMutex(name, true); + case FCNTL: + return new FcntlMutex(name, true); + } + throw new NotImplementedException(); + } + + public Mutex open(MutexType type, String name) + throws IllegalAccessException, + IllegalArgumentException, + NoSuchObjectException, + NotImplementedException, + SystemException + { + if (type == MutexType.DEFAULT) + type = mtype; + switch (type) { + case POSIXSEM: + return new PosixMutex(name, false); + case SYSVSEM: + return new SysVMutex(name, false); + case FCNTL: + return new FcntlMutex(name, false); + } + throw new NotImplementedException(); + } + +} + Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java?rev=1092669&r1=1092668&r2=1092669&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixSemaphore.java Fri Apr 15 11:41:44 2011 @@ -16,7 +16,6 @@ package org.apache.commons.runtime.platform.unix; import org.apache.commons.runtime.Semaphore; -import org.apache.commons.runtime.SemaphoreImpl; import org.apache.commons.runtime.Status; import org.apache.commons.runtime.exception.AlreadyExistsException; import org.apache.commons.runtime.exception.NoSuchObjectException; Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,51 @@ +/* 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.commons.runtime.platform.unix; + +import org.apache.commons.runtime.Mutex; +import org.apache.commons.runtime.Status; +import org.apache.commons.runtime.exception.AlreadyExistsException; +import org.apache.commons.runtime.exception.NoSuchObjectException; +import org.apache.commons.runtime.exception.NotImplementedException; +import org.apache.commons.runtime.exception.ClosedDescriptorException; +import org.apache.commons.runtime.exception.SystemException; + +/** + * SysVMutex class. + *

+ *

+ * + * @since Runtime 1.0 + */ +final class SysVMutex extends Mutex +{ + + private SysVMutex() + { + // No Instance + } + + public SysVMutex(final String name, boolean owner) + throws IllegalAccessException, + IllegalArgumentException, + AlreadyExistsException, + NotImplementedException, + SystemException + { + this.owner = true; + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutex.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutex.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutex.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutex.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,51 @@ +/* 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.commons.runtime.platform.windows; + +import org.apache.commons.runtime.Mutex; +import org.apache.commons.runtime.Status; +import org.apache.commons.runtime.exception.AlreadyExistsException; +import org.apache.commons.runtime.exception.NoSuchObjectException; +import org.apache.commons.runtime.exception.NotImplementedException; +import org.apache.commons.runtime.exception.ClosedDescriptorException; +import org.apache.commons.runtime.exception.SystemException; + +/** + * WindowsMutex class. + *

+ *

+ * + * @since Runtime 1.0 + */ +final class WindowsMutex extends Mutex +{ + + private WindowsMutex() + { + // No Instance + } + + public WindowsMutex(final String name, boolean owner) + throws IllegalAccessException, + IllegalArgumentException, + AlreadyExistsException, + NotImplementedException, + SystemException + { + this.owner = true; + } + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutex.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutexImpl.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutexImpl.java?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutexImpl.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutexImpl.java Fri Apr 15 11:41:44 2011 @@ -0,0 +1,70 @@ +/* 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.commons.runtime.platform.windows; + +import org.apache.commons.runtime.Mutex; +import org.apache.commons.runtime.MutexImpl; +import org.apache.commons.runtime.MutexType; +import org.apache.commons.runtime.exception.AlreadyExistsException; +import org.apache.commons.runtime.exception.NoSuchObjectException; +import org.apache.commons.runtime.exception.NotImplementedException; +import org.apache.commons.runtime.exception.SystemException; + +/** + * Windows MutexImpl class. + *

+ *

+ * + * @since Runtime 1.0 + */ +final class WindowsMutexImpl extends MutexImpl +{ + + public WindowsMutexImpl() + { + // No Instance + } + + public Mutex create(MutexType type, String name) + throws IllegalAccessException, + IllegalArgumentException, + AlreadyExistsException, + NotImplementedException, + SystemException + { + switch (type) { + case DEFAULT: + return new WindowsMutex(name, true); + } + throw new NotImplementedException(); + } + + public Mutex open(MutexType type, String name) + throws IllegalAccessException, + IllegalArgumentException, + NoSuchObjectException, + NotImplementedException, + SystemException + { + switch (type) { + case DEFAULT: + return new WindowsMutex(name, false); + } + throw new NotImplementedException(); + } + +} + Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsMutexImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=1092669&r1=1092668&r2=1092669&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Fri Apr 15 11:41:44 2011 @@ -79,6 +79,7 @@ WIN32_SOURCES=\ $(TOPDIR)\os\win32\init.c \ $(TOPDIR)\os\win32\os.c \ $(TOPDIR)\os\win32\platform.c \ + $(TOPDIR)\os\win32\procmutex.c \ $(TOPDIR)\os\win32\semaphore.c \ $(TOPDIR)\os\win32\time.c \ $(TOPDIR)\os\win32\util.c \ Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in?rev=1092669&r1=1092668&r2=1092669&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Fri Apr 15 11:41:44 2011 @@ -64,6 +64,7 @@ UNIX_SOURCES=\ $(TOPDIR)/os/unix/init.c \ $(TOPDIR)/os/unix/platform.c \ $(TOPDIR)/os/unix/posixapi.c \ + $(TOPDIR)/os/unix/procmutex.c \ $(TOPDIR)/os/unix/semaphore.c \ $(TOPDIR)/os/unix/time.c \ $(TOPDIR)/os/unix/util.c Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c Fri Apr 15 11:41:44 2011 @@ -0,0 +1,84 @@ +/* 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. + */ + +#include "acr/string.h" +#include "acr/clazz.h" +#include "acr/port.h" + +#include +#include +#include + +#if HAVE_SEMAPHORE_H +# include +#endif + +#ifndef SEM_FAILED +#define SEM_FAILED (-1) +#endif +#ifndef NAME_MAX +#define NAME_MAX (64) +#endif + +#define _DEFAULT_MUTEX_TYPE 0 +#if HAVE_POSIX_SEMAPHORE +# if defined(USE_POSIX_MUTEX) +# undef _DEFAULT_MUTEX_TYPE +# define _DEFAULT_MUTEX_TYPE 1 +# endif +#endif +#if defined(USE_SYSV_MUTEX) +# if _DEFAULT_MUTEX_TYPE +# error "Cannot have multiple mutex types" +# else +# undef _DEFAULT_MUTEX_TYPE +# define _DEFAULT_MUTEX_TYPE 1 +# endif +#endif +#if defined(USE_FCNTL_MUTEX) +# if _DEFAULT_MUTEX_TYPE +# error "Cannot have multiple mutex types" +# else +# undef _DEFAULT_MUTEX_TYPE +# define _DEFAULT_MUTEX_TYPE 3 +# endif +#endif +#if !_DEFAULT_MUTEX_TYPE +# error "Mutex type not configured" +#endif + +#define _PR_MUTEX_OWNER 0x00010000 +#if HAVE_POSIX_SEMAPHORE +static volatile unsigned int _proc_mutex_counter = 1; +#endif +#if !HAVE_UNION_SEMUN +union semun { + int val; + struct semid_ds *buf; + unsigned short *array; +}; +#endif + +typedef struct semblock_t { + acr_uint32_t magic; /* Is this our memeory */ + pid_t creator; /* Creator's process ID */ + acr_uint32_t value; /* Maximum semaphore value */ +} semblock_t; + +ACR_UNX_EXPORT(jint, PosixMutexImpl, getdefault0)(JNI_STDARGS) +{ + return _DEFAULT_MUTEX_TYPE; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c?rev=1092669&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c Fri Apr 15 11:41:44 2011 @@ -0,0 +1,21 @@ +/* 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. + */ + +#include "acr/string.h" +#include "acr/clazz.h" +#include "acr/port.h" +#include "arch_opts.h" + Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c ------------------------------------------------------------------------------ svn:eol-style = native