-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from qzhuyan/dev/william/buffer-stream-signals
buffer stream signals
- Loading branch information
Showing
12 changed files
with
465 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/*-------------------------------------------------------------------- | ||
Copyright (c) 2024 EMQ Technologies Co., Ltd. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-------------------------------------------------------------------*/ | ||
#include "quicer_owner_queue.h" | ||
|
||
OWNER_SIGNAL_QUEUE * | ||
OwnerSignalQueueNew() | ||
{ | ||
OWNER_SIGNAL_QUEUE *sig | ||
= CxPlatAlloc(sizeof(OWNER_SIGNAL_QUEUE), QUICER_OWNER_SIGNAL); | ||
return sig; | ||
} | ||
|
||
void | ||
OwnerSignalQueueInit(OWNER_SIGNAL_QUEUE *queue) | ||
{ | ||
queue->env = enif_alloc_env(); | ||
CxPlatListInitializeHead(&queue->List); | ||
} | ||
|
||
void | ||
OwnerSignalQueueDestroy(OWNER_SIGNAL_QUEUE *queue) | ||
{ | ||
CXPLAT_DBG_ASSERT(CxPlatListIsEmpty(&queue->List)); | ||
enif_free_env(queue->env); | ||
CxPlatFree(queue, QUICER_OWNER_SIGNAL); | ||
} | ||
|
||
OWNER_SIGNAL * | ||
OwnerSignalAlloc() | ||
{ | ||
OWNER_SIGNAL *sig = CxPlatAlloc(sizeof(OWNER_SIGNAL), QUICER_OWNER_SIGNAL); | ||
return sig; | ||
} | ||
|
||
void | ||
OwnerSignalFree(OWNER_SIGNAL *sig) | ||
{ | ||
CXPLAT_FREE(sig, QUICER_OWNER_SIGNAL); | ||
} | ||
|
||
void | ||
OwnerSignalEnqueue(_In_ OWNER_SIGNAL_QUEUE *queue, _In_ OWNER_SIGNAL *sig) | ||
{ | ||
CxPlatListInsertTail(&queue->List, &sig->Link); | ||
} | ||
|
||
OWNER_SIGNAL * | ||
OwnerSignalDequeue(_In_ OWNER_SIGNAL_QUEUE *queue) | ||
{ | ||
OWNER_SIGNAL *sig; | ||
if (CxPlatListIsEmpty(&queue->List)) | ||
{ | ||
sig = NULL; | ||
} | ||
else | ||
{ | ||
sig = CXPLAT_CONTAINING_RECORD( | ||
CxPlatListRemoveHead(&queue->List), OWNER_SIGNAL, Link); | ||
} | ||
|
||
return sig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*-------------------------------------------------------------------- | ||
Copyright (c) 2024 EMQ Technologies Co., Ltd. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-------------------------------------------------------------------*/ | ||
#ifndef QUICER_OWNER_QUEUE_H_ | ||
#define QUICER_OWNER_QUEUE_H_ | ||
|
||
#include <erl_nif.h> | ||
|
||
// clang-format off | ||
#include <quicer_internal.h> | ||
#include <msquic.h> | ||
#include <quic_platform.h> | ||
// clang-format on | ||
|
||
#define QUICER_OWNER_SIGNAL 'E0rQ' // 'Er0d' QUICER_OWNER_SIGNAL | ||
|
||
// Owner Signal Queue | ||
typedef struct OWNER_SIGNAL_QUEUE | ||
{ | ||
ErlNifEnv *env; | ||
CXPLAT_LIST_ENTRY List; | ||
} OWNER_SIGNAL_QUEUE; | ||
|
||
typedef struct OWNER_SIGNAL | ||
{ | ||
CXPLAT_LIST_ENTRY Link; | ||
ERL_NIF_TERM msg; // resides in `env` of OWNER_SIGNAL_QUEUE | ||
ERL_NIF_TERM orig_owner; // owner when msg is generated | ||
} OWNER_SIGNAL; | ||
|
||
OWNER_SIGNAL_QUEUE *OwnerSignalQueueNew(); | ||
OWNER_SIGNAL *OwnerSignalAlloc(); | ||
void OwnerSignalQueueInit(OWNER_SIGNAL_QUEUE *queue); | ||
void OwnerSignalQueueDestroy(OWNER_SIGNAL_QUEUE *queue); | ||
void OwnerSignalFree(OWNER_SIGNAL *sig); | ||
void OwnerSignalEnqueue(_In_ OWNER_SIGNAL_QUEUE *queue, | ||
_In_ OWNER_SIGNAL *sig); | ||
OWNER_SIGNAL *OwnerSignalDequeue(_In_ OWNER_SIGNAL_QUEUE *queue); | ||
|
||
#endif // QUICER_OWNER_QUEUE_H_ |
Oops, something went wrong.