MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / enqueue

Method enqueue

src/jrd/svc.cpp:2280–2325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2278#define ENQUEUE_DEQUEUE_DELAY 1
2279
2280void Service::enqueue(const UCHAR* s, ULONG len)
2281{
2282 if (checkForShutdown() || (svc_flags & SVC_detached))
2283 {
2284 unblockQueryGet();
2285 return;
2286 }
2287
2288 while (len)
2289 {
2290 // Wait for space in buffer
2291 bool flagFirst = true;
2292 while (full())
2293 {
2294 if (flagFirst)
2295 {
2296 unblockQueryGet(true);
2297 flagFirst = false;
2298 }
2299 svc_sem_empty.tryEnter(1, 0);
2300 if (checkForShutdown() || (svc_flags & SVC_detached))
2301 {
2302 unblockQueryGet();
2303 return;
2304 }
2305 }
2306
2307 const ULONG head = svc_stdout_head;
2308 ULONG cnt = (head > svc_stdout_tail ? head : sizeof(svc_stdout)) - 1;
2309 if (add_one(cnt) != head)
2310 {
2311 ++cnt;
2312 }
2313 cnt -= svc_stdout_tail;
2314 if (cnt > len)
2315 {
2316 cnt = len;
2317 }
2318
2319 memcpy(&svc_stdout[svc_stdout_tail], s, cnt);
2320 svc_stdout_tail = add_val(svc_stdout_tail, cnt);
2321 s += cnt;
2322 len -= cnt;
2323 }
2324 unblockQueryGet();
2325}
2326
2327
2328void Service::unblockQueryGet(bool over)

Callers 2

enqueueFunction · 0.45
internal_enqueueFunction · 0.45

Calls 1

tryEnterMethod · 0.45

Tested by

no test coverage detected