00001 #include "ace_pch.h"
00002
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
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
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
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
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
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
00066 this->remove (this->unlink_in_destructor_);
00067 }
00068
00069
00070
00071 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00072
00073
00074
00075 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00076
00077
00078
00079 #endif