Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
dart::PendingCall Class Reference

Public Member Functions

 PendingCall (void **buffer, size_t *length)
 
 ~PendingCall ()
 
Dart_Port port () const
 
void PostAndWait (Dart_Port port, Dart_CObject *object)
 

Static Public Member Functions

static void HandleResponse (Dart_Port p, Dart_CObject *message)
 

Detailed Description

Definition at line 628 of file ffi_test_functions_vmspecific.cc.

Constructor & Destructor Documentation

◆ PendingCall()

dart::PendingCall::PendingCall ( void **  buffer,
size_t *  length 
)
inline

Definition at line 630 of file ffi_test_functions_vmspecific.cc.

631 : response_buffer_(buffer), response_length_(length) {
632 receive_port_ =
633 Dart_NewNativePort_DL("cpp-response", &PendingCall::HandleResponse,
634 /*handle_concurrently=*/false);
635 }
static void HandleResponse(Dart_Port p, Dart_CObject *message)
static const uint8_t buffer[]
size_t length

◆ ~PendingCall()

dart::PendingCall::~PendingCall ( )
inline

Definition at line 636 of file ffi_test_functions_vmspecific.cc.

636{ Dart_CloseNativePort_DL(receive_port_); }

Member Function Documentation

◆ HandleResponse()

static void dart::PendingCall::HandleResponse ( Dart_Port  p,
Dart_CObject message 
)
inlinestatic

Definition at line 651 of file ffi_test_functions_vmspecific.cc.

651 {
652 if (message->type != Dart_CObject_kArray) {
653 FATAL("C : Wrong Data: message->type != Dart_CObject_kArray.\n");
654 }
655 Dart_CObject** c_response_args = message->value.as_array.values;
656 Dart_CObject* c_pending_call = c_response_args[0];
657 Dart_CObject* c_message = c_response_args[1];
658 printf("C : HandleResponse (call: %" Px ", message: %" Px ").\n",
659 reinterpret_cast<intptr_t>(c_pending_call),
660 reinterpret_cast<intptr_t>(c_message));
661
662 auto pending_call = reinterpret_cast<PendingCall*>(
663 c_pending_call->type == Dart_CObject_kInt64
664 ? c_pending_call->value.as_int64
665 : c_pending_call->value.as_int32);
666
667 pending_call->ResolveCall(c_message);
668 }
PendingCall(void **buffer, size_t *length)
@ Dart_CObject_kInt64
@ Dart_CObject_kArray
#define FATAL(error)
Win32Message message
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
#define Px
Definition globals.h:410
union _Dart_CObject::@86 value
Dart_CObject_Type type
struct _Dart_CObject::@86::@89 as_array
struct _Dart_CObject ** values

◆ port()

Dart_Port dart::PendingCall::port ( ) const
inline

Definition at line 638 of file ffi_test_functions_vmspecific.cc.

638{ return receive_port_; }

◆ PostAndWait()

void dart::PendingCall::PostAndWait ( Dart_Port  port,
Dart_CObject object 
)
inline

Definition at line 640 of file ffi_test_functions_vmspecific.cc.

640 {
641 std::unique_lock<std::mutex> lock(mutex);
642 const bool success = Dart_PostCObject_DL(port, object);
643 if (!success) FATAL("Failed to send message, invalid port or isolate died");
644
645 printf("C : Waiting for result.\n");
646 while (!notified) {
647 cv.wait(lock);
648 }
649 }

The documentation for this class was generated from the following file: