File_Lock.cpp

Go to the documentation of this file.
00001 // File_Lock.cpp,v 4.5 2005/10/28 16:14:52 ossama Exp
00002 
00003 #include "ace/File_Lock.h"
00004 #include "ace/Log_Msg.h"
00005 
00006 #if !defined (__ACE_INLINE__)
00007 #include "ace/File_Lock.inl"
00008 #endif /* __ACE_INLINE__ */
00009 
00010 ACE_RCSID(ace, File_Lock, "File_Lock.cpp,v 4.5 2005/10/28 16:14:52 ossama Exp")
00011 
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 ACE_ALLOC_HOOK_DEFINE(ACE_File_Lock)
00015 
00016 void
00017 ACE_File_Lock::dump (void) const
00018 {
00019 #if defined (ACE_HAS_DUMP)
00020 // ACE_TRACE ("ACE_File_Lock::dump");
00021 
00022   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00023   this->lock_.dump ();
00024   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00025 #endif /* ACE_HAS_DUMP */
00026 }
00027 
00028 ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h,
00029                               int unlink_in_destructor)
00030   : removed_ (0),
00031     unlink_in_destructor_ (unlink_in_destructor)
00032 {
00033 // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
00034   if (ACE_OS::flock_init (&this->lock_) == -1)
00035     ACE_ERROR ((LM_ERROR,
00036                 ACE_LIB_TEXT ("%p\n"),
00037                 ACE_LIB_TEXT ("ACE_File_Lock::ACE_File_Lock")));
00038   this->set_handle (h);
00039 }
00040 
00041 ACE_File_Lock::ACE_File_Lock (const ACE_TCHAR *name,
00042                               int flags,
00043                               mode_t perms,
00044                               int unlink_in_destructor)
00045   : unlink_in_destructor_ (unlink_in_destructor)
00046 {
00047 // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
00048 
00049   if (this->open (name, flags, perms) == -1)
00050     ACE_ERROR ((LM_ERROR,
00051                 ACE_LIB_TEXT ("%p %s\n"),
00052                 ACE_LIB_TEXT ("ACE_File_Lock::ACE_File_Lock"),
00053                 name));
00054 }
00055 
00056 int
00057 ACE_File_Lock::open (const ACE_TCHAR *name,
00058                      int flags,
00059                      mode_t perms)
00060 {
00061 // ACE_TRACE ("ACE_File_Lock::open");
00062   this->removed_ = 0;
00063   return ACE_OS::flock_init (&this->lock_, flags, name, perms);
00064 }
00065 
00066 ACE_File_Lock::~ACE_File_Lock (void)
00067 {
00068 // ACE_TRACE ("ACE_File_Lock::~ACE_File_Lock");
00069   this->remove (this->unlink_in_destructor_);
00070 }
00071 
00072 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:51 2006 for ACE by doxygen 1.3.6