aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index f8d6cdc..4ab89ab 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -106,8 +106,10 @@ template <bool OPT>
106} 106}
107 107
108// ################################################################################################# 108// #################################################################################################
109// #################################################################################################
109// #################################### Linda implementation ####################################### 110// #################################### Linda implementation #######################################
110// ################################################################################################# 111// #################################################################################################
112// #################################################################################################
111 113
112Linda::Linda(Universe* U_, LindaGroup group_, std::string_view const& name_) 114Linda::Linda(Universe* U_, LindaGroup group_, std::string_view const& name_)
113: DeepPrelude{ LindaFactory::Instance } 115: DeepPrelude{ LindaFactory::Instance }
@@ -126,6 +128,18 @@ Linda::~Linda()
126 128
127// ################################################################################################# 129// #################################################################################################
128 130
131Keeper* Linda::acquireKeeper() const
132{
133 // can be nullptr if this happens during main state shutdown (lanes is being GC'ed -> no keepers)
134 Keeper* const _K{ whichKeeper() };
135 if (_K) {
136 _K->mutex.lock();
137 }
138 return _K;
139}
140
141// #################################################################################################
142
129void Linda::freeAllocatedName() 143void Linda::freeAllocatedName()
130{ 144{
131 if (std::holds_alternative<std::string_view>(nameVariant)) { 145 if (std::holds_alternative<std::string_view>(nameVariant)) {
@@ -186,6 +200,16 @@ int Linda::ProtectedCall(lua_State* L_, lua_CFunction f_)
186 200
187// ################################################################################################# 201// #################################################################################################
188 202
203void Linda::releaseKeeper(Keeper* const K_) const
204{
205 if (K_) { // can be nullptr if we tried to acquire during shutdown
206 assert(K_ == whichKeeper());
207 K_->mutex.unlock();
208 }
209}
210
211// #################################################################################################
212
189void Linda::setName(std::string_view const& name_) 213void Linda::setName(std::string_view const& name_)
190{ 214{
191 // keep default 215 // keep default
@@ -210,8 +234,10 @@ void Linda::setName(std::string_view const& name_)
210} 234}
211 235
212// ################################################################################################# 236// #################################################################################################
237// #################################################################################################
213// ########################################## Lua API ############################################## 238// ########################################## Lua API ##############################################
214// ################################################################################################# 239// #################################################################################################
240// #################################################################################################
215 241
216/* 242/*
217 * (void) = linda_cancel( linda_ud, "read"|"write"|"both"|"none") 243 * (void) = linda_cancel( linda_ud, "read"|"write"|"both"|"none")