Skip to content

Commit

Permalink
LibThread: Lockable - add forwarding constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
tryfinally authored and awesomekling committed Aug 14, 2020
1 parent 746f6ea commit 33cb41e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Libraries/LibThread/Lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@

#ifdef __serenity__

#include <AK/Assertions.h>
#include <AK/Types.h>
#include <AK/Atomic.h>
#include <unistd.h>
# include <AK/Assertions.h>
# include <AK/Atomic.h>
# include <AK/Types.h>
# include <unistd.h>

namespace LibThread {

class Lock {
public:
Lock() {}
~Lock() {}
Lock() { }
~Lock() { }

void lock();
void unlock();
Expand Down Expand Up @@ -90,12 +90,19 @@ inline void Lock::unlock()
--m_level;
}

#define LOCKER(lock) LibThread::Locker locker(lock)
# define LOCKER(lock) LibThread::Locker locker(lock)

template<typename T>
class Lockable {
public:
Lockable() {}
Lockable() { }

template<typename... Args>
Lockable(Args&&... args)
: m_resource(forward(args)...)
{
}

Lockable(T&& resource)
: m_resource(move(resource))
{
Expand Down Expand Up @@ -128,6 +135,6 @@ class Lock {

}

#define LOCKER(x)
# define LOCKER(x)

#endif

0 comments on commit 33cb41e

Please sign in to comment.