Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

File_Lock.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: File_Lock.cpp,v 1.1.1.1.40.1 2003/03/13 19:44:21 chad Exp $
00003 
00004 #include "ace/File_Lock.h"
00005 #include "ace/Log_Msg.h"
00006 
00007 #if !defined (__ACE_INLINE__)
00008 #include "ace/File_Lock.inl"
00009 #endif /* __ACE_INLINE__ */
00010 
00011 ACE_RCSID(ace, File_Lock, "$Id: File_Lock.cpp,v 1.1.1.1.40.1 2003/03/13 19:44:21 chad Exp $")
00012 
00013 ACE_ALLOC_HOOK_DEFINE(ACE_File_Lock)
00014 
00015 void
00016 ACE_File_Lock::dump (void) const
00017 {
00018 // ACE_TRACE ("ACE_File_Lock::dump");
00019 
00020   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00021   this->lock_.dump ();
00022   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00023 }
00024 
00025 ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h,
00026                               int unlink_in_destructor)
00027   : removed_ (0),
00028     unlink_in_destructor_ (unlink_in_destructor)
00029 {
00030 // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
00031   if (ACE_OS::flock_init (&this->lock_) == -1)
00032     ACE_ERROR ((LM_ERROR,
00033                 ACE_LIB_TEXT ("%p\n"),
00034                 ACE_LIB_TEXT ("ACE_File_Lock::ACE_File_Lock")));
00035   this->set_handle (h);
00036 }
00037 
00038 ACE_File_Lock::ACE_File_Lock (const ACE_TCHAR *name,
00039                               int flags,
00040                               mode_t perms,
00041                               int unlink_in_destructor)
00042   : unlink_in_destructor_ (unlink_in_destructor)
00043 {
00044 // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
00045 
00046   if (this->open (name, flags, perms) == -1)
00047     ACE_ERROR ((LM_ERROR,
00048                 ACE_LIB_TEXT ("%p %s\n"),
00049                 ACE_LIB_TEXT ("ACE_File_Lock::ACE_File_Lock"),
00050                 name));
00051 }
00052 
00053 int
00054 ACE_File_Lock::open (const ACE_TCHAR *name,
00055                      int flags,
00056                      mode_t perms)
00057 {
00058 // ACE_TRACE ("ACE_File_Lock::open");
00059   this->removed_ = 0;
00060   return ACE_OS::flock_init (&this->lock_, flags, name, perms);
00061 }
00062 
00063 ACE_File_Lock::~ACE_File_Lock (void)
00064 {
00065 // ACE_TRACE ("ACE_File_Lock::~ACE_File_Lock");
00066   this->remove (this->unlink_in_destructor_);
00067 }
00068 
00069 // These are instantiated both with and without ACE_HAS_THREADS.
00070 
00071 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00072 
00073 // template class ACE_Guard<ACE_File_Lock>;
00074 
00075 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00076 
00077 // #pragma instantiate ACE_Guard<ACE_File_Lock>
00078 
00079 #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */

Generated on Mon Jun 16 11:19:41 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002