GitHub Actions: Try MSVC builds with /std:c++17 and 20
[ACE_TAO.git] / ACE / ace / File_Lock.cpp
blobf5e421acb25aefa5118e24209ffe0cd87762908e
1 #include "ace/File_Lock.h"
2 #include "ace/Log_Category.h"
3 #if defined (ACE_HAS_ALLOC_HOOKS)
4 # include "ace/Malloc_Base.h"
5 #endif /* ACE_HAS_ALLOC_HOOKS */
7 #if !defined (__ACE_INLINE__)
8 #include "ace/File_Lock.inl"
9 #endif /* __ACE_INLINE__ */
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_ALLOC_HOOK_DEFINE(ACE_File_Lock)
17 void
18 ACE_File_Lock::dump (void) const
20 #if defined (ACE_HAS_DUMP)
21 // ACE_TRACE ("ACE_File_Lock::dump");
23 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
24 this->lock_.dump ();
25 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
26 #endif /* ACE_HAS_DUMP */
29 ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h,
30 bool unlink_in_destructor)
31 : removed_ (false),
32 unlink_in_destructor_ (unlink_in_destructor)
34 // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
35 if (ACE_OS::flock_init (&this->lock_) == -1)
36 ACELIB_ERROR ((LM_ERROR,
37 ACE_TEXT ("%p\n"),
38 ACE_TEXT ("ACE_File_Lock::ACE_File_Lock")));
39 this->set_handle (h);
42 ACE_File_Lock::ACE_File_Lock (const ACE_TCHAR *name,
43 int flags,
44 mode_t perms,
45 bool unlink_in_destructor)
46 : unlink_in_destructor_ (unlink_in_destructor)
48 // ACE_TRACE ("ACE_File_Lock::ACE_File_Lock");
50 if (this->open (name, flags, perms) == -1)
51 ACELIB_ERROR ((LM_ERROR,
52 ACE_TEXT ("%p %s\n"),
53 ACE_TEXT ("ACE_File_Lock::ACE_File_Lock"),
54 name));
57 int
58 ACE_File_Lock::open (const ACE_TCHAR *name,
59 int flags,
60 mode_t perms)
62 // ACE_TRACE ("ACE_File_Lock::open");
63 this->removed_ = false;
64 return ACE_OS::flock_init (&this->lock_, flags, name, perms);
67 ACE_File_Lock::~ACE_File_Lock (void)
69 // ACE_TRACE ("ACE_File_Lock::~ACE_File_Lock");
70 this->remove (this->unlink_in_destructor_);
73 ACE_END_VERSIONED_NAMESPACE_DECL