SynchronizedAccessor.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00018 package com.generalrobotix.ui.util;
00019 import java.util.concurrent.TimeUnit;
00020 import java.util.concurrent.locks.Condition;
00021 import java.util.concurrent.locks.ReentrantLock;
00022 import java.util.concurrent.locks.Lock;
00023 
00024 public class SynchronizedAccessor < T extends java.lang.Object >
00025     implements Lock
00026 {
00027     private T value_ = null;
00028     private ReentrantLock reentrantLock_ = new ReentrantLock(); 
00029 
00030     public SynchronizedAccessor(T val){
00031         value_ = val;
00032     }
00033     
00034     public synchronized T get(){ return value_; }
00035     public synchronized void set(T val){ value_ = val; }
00036 
00037     public void lock()
00038     {
00039         // TODO 自動生成されたメソッド・スタブ
00040         reentrantLock_.lock();
00041     }
00042 
00043     public void lockInterruptibly()
00044             throws InterruptedException
00045     {
00046         // TODO 自動生成されたメソッド・スタブ
00047         reentrantLock_.lockInterruptibly();
00048     }
00049 
00050     public Condition newCondition()
00051     {
00052         // TODO 自動生成されたメソッド・スタブ
00053         return reentrantLock_.newCondition();
00054     }
00055 
00056     public boolean tryLock()
00057     {
00058         // TODO 自動生成されたメソッド・スタブ
00059         return reentrantLock_.tryLock();
00060     }
00061 
00062     public boolean tryLock(long time, TimeUnit unit)
00063             throws InterruptedException
00064     {
00065         // TODO 自動生成されたメソッド・スタブ
00066         return reentrantLock_.tryLock(time, unit);
00067     }
00068 
00069     public void unlock()
00070     {
00071         // TODO 自動生成されたメソッド・スタブ
00072         reentrantLock_.unlock();
00073     }
00074 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:57