本文整理匯總了C++中ACE_GUARD_RETURN函數的典型用法代碼示例。如果您正苦於以下問題:C++ ACE_GUARD_RETURN函數的具體用法?C++ ACE_GUARD_RETURN怎麽用?C++ ACE_GUARD_RETURN使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ACE_GUARD_RETURN函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ACE_TRACE
template <class TYPE, class FUNCTOR, class ACE_LOCK> int
ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
const void **act,
int dont_call)
{
ACE_TRACE ("ACE_Timer_List_T::cancel");
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
// Make sure we are getting a valid <timer_id>, not an error
// returned by schedule ()
if (timer_id == -1)
return 0;
ACE_Timer_Node_T<TYPE> *node =
ACE_reinterpret_cast (ACE_Timer_Node_T<TYPE> *,
timer_id);
// Check to see if the node looks like a true ACE_Timer_Node_T<TYPE>
if (timer_id == node->get_timer_id ())
{
node->get_next ()->set_prev (node->get_prev ());
node->get_prev ()->set_next (node->get_next ());
if (act != 0)
*act = node->get_act ();
if (dont_call == 0)
this->upcall_functor ().cancellation (*this,
node->get_type ());
this->free_node (node);
return 1;
}
// Wasn't valid
return 0;
}
示例2: ACE_TRACE
void *
ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors)
{
ACE_TRACE ("ACE_DLL_Handle::symbol");
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));
ACE_Auto_Array_Ptr <ACE_TCHAR> auto_name (ACE::ldname (sym_name));
// handle_ can be invalid especially when ACE_DLL_Handle resigned ownership
// BTW. Handle lifecycle management is a little crazy in ACE
if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)
{
#if defined (ACE_OPENVMS)
void *sym = ACE::ldsymbol (this->handle_, auto_name.get ());
#else
void *sym = ACE_OS::dlsym (this->handle_, auto_name.get ());
#endif
// Linux says that the symbol could be null and that it isn't an
// error. So you should check the error message also, but since
// null symbols won't do us much good anyway, let's still report
// an error.
if (!sym && ignore_errors != 1)
{
if (ACE::debug ())
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ACE (%P|%t) DLL_Handle::symbol (\"%s\") ")
ACE_TEXT (" failed with \"%s\".\n"),
auto_name.get (),
this->error ()->c_str ()));
return 0;
}
return sym;
}
return 0;
}
示例3: defined
ACE_UINT32
ACE_High_Res_Timer::global_scale_factor (void)
{
#if (defined (ACE_WIN32) || defined (ACE_HAS_POWERPC_TIMER) || \
defined (ACE_HAS_PENTIUM) || defined (ACE_HAS_ALPHA_TIMER)) && \
!defined (ACE_HAS_HI_RES_TIMER) && \
((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \
defined (ghs) || defined (__GNUG__) || defined (__KCC))
// Check if the global scale factor needs to be set, and do if so.
if (ACE_High_Res_Timer::global_scale_factor_status_ == 0)
{
// Grab ACE's static object lock. This doesn't have anything to
// do with static objects; it's just a convenient lock to use.
ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance (), 0));
// Double check
if (ACE_High_Res_Timer::global_scale_factor_status_ == 0)
{
# if defined (ACE_WIN32)
LARGE_INTEGER freq;
if (::QueryPerformanceFrequency (&freq))
{
// We have a high-res timer
# if defined (ghs)
ACE_UINT64 uint64_freq(freq.u.LowPart, (ACE_UINT32) freq.u.HighPart);
ACE_High_Res_Timer::global_scale_factor
(uint64_freq / (ACE_UINT32) ACE_ONE_SECOND_IN_USECS);
# else
ACE_High_Res_Timer::global_scale_factor
(ACE_static_cast (unsigned int,
freq.QuadPart / ACE_HR_SCALE_CONVERSION));
# endif // (ghs)
ACE_High_Res_Timer::global_scale_factor_status_ = 1;
}
示例4: ACE_ERROR
Monitor_Control_Types::NameList
Monitor_Base::get_list (void) const
{
Monitor_Control_Types::NameList retval;
if(this->data_.type_ != Monitor_Control_Types::MC_LIST)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("get_list: %s is not a ")
ACE_TEXT ("list monitor type\n"),
this->name_.c_str ()));
return retval;
}
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, retval);
for(size_t i = 0UL; i < this->data_.index_; ++i)
{
retval.push_back (this->data_.list_[i]);
}
return retval;
}
示例5: ACE_GUARD_RETURN
BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battleground* bg)
{
// load/create a map
ACE_GUARD_RETURN(ACE_Thread_Mutex, Guard, Lock, NULL);
sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateBattleground: map bg %d for %d created.", InstanceId, GetId());
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),bg->GetMinLevel());
uint8 spawnMode;
if (bracketEntry)
spawnMode = bracketEntry->difficulty;
else
spawnMode = REGULAR_DIFFICULTY;
BattlegroundMap *map = new BattlegroundMap(GetId(), GetGridExpiry(), InstanceId, this, spawnMode);
ASSERT(map->IsBattlegroundOrArena());
map->SetBG(bg);
bg->SetBgMap(map);
m_InstancedMaps[InstanceId] = map;
return map;
}
示例6: ACE_TRACE
ssize_t
ACE_MT_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf,
int flags,
const ACE_Time_Value *timeout)
{
ACE_TRACE ("ACE_MT_MEM_IO::recv_buf");
// @@ Don't know how to handle timeout yet.
ACE_UNUSED_ARG (timeout);
ACE_UNUSED_ARG (flags);
if (this->shm_malloc_ == 0)
{
return -1;
}
// Need to handle timeout here.
if (this->recv_channel_.sema_->acquire () == -1)
{
return -1;
}
{
// @@ We can probably skip the lock in certain circumstance.
ACE_GUARD_RETURN (ACE_SYNCH_PROCESS_MUTEX, ace_mon, *this->recv_channel_.lock_, -1);
buf = this->recv_channel_.queue_.read ();
if (buf != 0)
{
return ACE_Utils::truncate_cast<ssize_t> (buf->size ());
}
return -1;
}
}
示例7: ACE_TRACE
ACE_Framework_Repository *
ACE_Framework_Repository::instance (int size)
{
ACE_TRACE ("ACE_Framework_Repository::instance");
if (ACE_Framework_Repository::repository_ == 0)
{
// Perform Double-Checked Locking Optimization.
ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance (), 0));
if (ACE_Framework_Repository::repository_ == 0)
{
if (ACE_Object_Manager::starting_up () ||
!ACE_Object_Manager::shutting_down ())
{
ACE_NEW_RETURN (ACE_Framework_Repository::repository_,
ACE_Framework_Repository (size),
0);
}
}
}
return ACE_Framework_Repository::repository_;
}
示例8: ACE_GUARD_RETURN
bool
Random_File::open(const ACE_TCHAR* filename, size_t block_size)
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, false);
this->block_size_ = block_size;
bool result = (this->close() == 0);
if (result)
{
if (DEBUG_LEVEL > 8) ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Opening file %s\n")
, filename
));
ACE_HANDLE handle = ACE_OS::open(filename,
O_CREAT | O_RDWR | O_BINARY,
ACE_DEFAULT_FILE_PERMS);
if (handle == ACE_INVALID_HANDLE)
{
result = false;
}
else
{
this->set_handle(handle);
if (this->get_handle() == 0)
{
result = false;
}
else
{
result = (this->addr_.set(filename) == 0);
}
}
}
return result;
}
示例9: defined
const ACE_INET_Addr &
TAO_SSLIOP_Endpoint::object_addr (void) const
{
// The object_addr_ is initialized here, rather than at IOR decode
// time for several reasons:
// 1. A request on the object may never be invoked.
// 2. The DNS setup may have changed dynamically.
// ...etc..
// Double checked locking optimization.
if (this->object_addr_.get_type () != AF_INET
#if defined (ACE_HAS_IPV6)
&& this->object_addr_.get_type () != AF_INET6
#endif /* ACE_HAS_IPV6 */
)
{
const ACE_INET_Addr &iiop_addr = this->iiop_endpoint_->object_addr ();
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
guard,
this->addr_lookup_lock_,
this->object_addr_);
if (this->object_addr_.get_type () != AF_INET
#if defined (ACE_HAS_IPV6)
&& this->object_addr_.get_type () != AF_INET6
#endif /* ACE_HAS_IPV6 */
)
{
this->object_addr_ = iiop_addr;
this->object_addr_.set_port_number (this->ssl_component_.port);
}
}
return this->object_addr_;
}
示例10: ACE_GUARD_RETURN
Sender *
Connection_Cache::acquire_connection (void)
{
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0);
// Find a valid and IDLE sender.
int index = -1;
for (int i = 0; i < number_of_connections; ++i)
{
if (this->entries_[i].sender_ &&
this->entries_[i].state_ == IDLE)
index = i;
}
if (index == -1)
return 0;
this->entries_[index].sender_->add_reference ();
this->entries_[index].state_ = BUSY;
return this->entries_[index].sender_;
}
示例11: ACE_GUARD_RETURN
CosNotifyChannelAdmin::SupplierAdmin_ptr
TAO_Notify_EventChannel::default_supplier_admin (void)
{
if (CORBA::is_nil (default_supplier_admin_.in ()))
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->default_admin_mutex_, CosNotifyChannelAdmin::SupplierAdmin::_nil());
if (CORBA::is_nil (default_supplier_admin_.in ()))
{
CosNotifyChannelAdmin::AdminID id;
this->default_supplier_admin_ =
this->new_for_suppliers (TAO_Notify_PROPERTIES::instance ()->defaultSupplierAdminFilterOp(), id);
PortableServer::ServantBase * admin_servant =
this->poa()->poa()->reference_to_servant (
this->default_supplier_admin_.in ());
TAO_Notify_Admin * pAdmin = dynamic_cast <TAO_Notify_Admin *> (admin_servant);
ACE_ASSERT (pAdmin != 0); // if this assert triggers, we have mixed implementations?
if (pAdmin != 0)
{
pAdmin->set_default (true);
}
}
}
return CosNotifyChannelAdmin::SupplierAdmin::_duplicate (this->default_supplier_admin_.in ());
}
示例12: ACE_GUARD_RETURN
template <PR_ST_1, ACE_SYNCH_DECL> int
ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::put (ACE_Message_Block *mb,
ACE_Time_Value *tv)
{
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1);
// Enqueue <mb> onto the message queue.
if (this->putq (mb, tv) == -1)
return -1;
else
{
// Update the current number of bytes on the queue.
this->current_buffer_size_ += mb->total_size ();
// Flush the buffer when the number of bytes exceeds the maximum
// buffer size or when the timeout period has elapsed.
if (this->current_buffer_size_ >= this->maximum_buffer_size_
|| (this->timeoutp_ != 0
&& this->next_timeout_ <= ACE_OS::gettimeofday ()))
return this->flush_i ();
else
return 0;
}
}
示例13: ACE_TRACE
int
ACE_Based_Pointer_Repository::find (void *addr,
void *&base_addr)
{
ACE_TRACE ("ACE_Based_Pointer_Repository::find");
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1);
ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0;
for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_);
iter.next (ce) != 0;
iter.advance ())
// Check to see if <addr> is within any of the regions.
if (addr >= ce->ext_id_
&& addr < ((char *) ce->ext_id_ + ce->int_id_))
{
// Assign the base address.
base_addr = ce->ext_id_;
return 1;
}
// Assume base address 0 (e.g., if new'ed).
base_addr = 0;
return 0;
}
示例14: ACE_MT
long
TRB_Proactor::schedule_timer (TRB_Handler &handler,
const void *act,
const ACE_Time_Value &time,
const ACE_Time_Value &interval)
{
// absolute time.
ACE_Time_Value absolute_time =
this->timer_queue_->gettimeofday () + time;
// Only one guy goes in here at a time
ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX,
ace_mon,
this->timer_queue_->mutex (),
-1));
// Schedule the timer
long result = this->timer_queue_->schedule (&handler,
act,
absolute_time,
interval);
if (result != -1)
{
// no failures: check to see if we are the earliest time
if (this->timer_queue_->earliest_time () == absolute_time)
// wake up the timer thread
if (this->timer_handler_->timer_event_.signal () == -1)
{
// Cancel timer
this->timer_queue_->cancel (result);
result = -1;
}
}
return result;
}
示例15: ACE_GUARD_RETURN
int
TAO_Table_Adapter::dispatch (TAO::ObjectKey &key,
TAO_ServerRequest &request,
CORBA::Object_out forward_to)
{
TAO_IOR_Table_Impl_var rootref;
{
ACE_GUARD_RETURN (ACE_Lock,
ace_mon,
*this->lock_,
TAO_Adapter::DS_MISMATCHED_KEY);
if (this->closed_)
return TAO_Adapter::DS_MISMATCHED_KEY;
rootref = this->root_;
}
if (this->find_object (key, forward_to))
{
request.forward_location (forward_to);
return TAO_Adapter::DS_FORWARD;
}
else
return TAO_Adapter::DS_MISMATCHED_KEY;
}